feat: add langchain

pull/643/head^2
Travis Fischer 2024-06-02 03:06:45 -05:00
rodzic e6263fbeac
commit 83cf65f9d0
12 zmienionych plików z 584 dodań i 14 usunięć

Wyświetl plik

@ -5,14 +5,14 @@ import { openai } from '@ai-sdk/openai'
import { generateText } from 'ai'
import { WeatherClient } from '../../src/index.js'
import { tools } from '../../src/sdks/ai-sdk.js'
import { createAISDKTools } from '../../src/sdks/ai-sdk.js'
async function main() {
const weather = new WeatherClient()
const result = await generateText({
model: openai('gpt-4-turbo'),
tools: tools(weather),
tools: createAISDKTools(weather),
toolChoice: 'required',
prompt:
'What is the weather in San Francisco and what attractions should I visit?'

Wyświetl plik

@ -10,7 +10,7 @@ import {
import { z } from 'zod'
import { WeatherClient } from '../../src/index.js'
import { functions } from '../../src/sdks/dexter.js'
import { createDexterFunctions } from '../../src/sdks/dexter.js'
/** Get the capital city for a given state. */
const getCapitalCity = createAIFunction(
@ -48,7 +48,7 @@ const weather = new WeatherClient()
/** A runner that uses the weather and capital city functions. */
const weatherCapitalRunner = createAIRunner({
chatModel: new ChatModel({ params: { model: 'gpt-4-1106-preview' } }),
functions: [...functions(weather), getCapitalCity],
functions: [...createDexterFunctions(weather), getCapitalCity],
systemMessage: `You use functions to answer questions about the weather and capital cities.`
})

Wyświetl plik

@ -6,7 +6,7 @@ import { configureGenkit } from '@genkit-ai/core'
import { gpt4o, openAI } from 'genkitx-openai'
import { WeatherClient } from '../../src/index.js'
import { tools } from '../../src/sdks/genkit.js'
import { createGenkitTools } from '../../src/sdks/genkit.js'
async function main() {
const weather = new WeatherClient()
@ -17,7 +17,7 @@ async function main() {
const result = await generate({
model: gpt4o,
tools: tools(weather),
tools: createGenkitTools(weather),
history: [
{
role: 'system',
@ -28,7 +28,7 @@ async function main() {
]
}
],
prompt: [{ text: 'What is the weather in San Francisco?' }]
prompt: 'What is the weather in San Francisco?'
})
console.log(result)

Wyświetl plik

@ -0,0 +1,39 @@
#!/usr/bin/env node
import 'dotenv/config'
import { ChatPromptTemplate } from '@langchain/core/prompts'
import { ChatOpenAI } from '@langchain/openai'
import { AgentExecutor, createToolCallingAgent } from 'langchain/agents'
import { WeatherClient } from '../../src/index.js'
import { createLangChainTools } from '../../src/sdks/langchain.js'
async function main() {
const weather = new WeatherClient()
const tools = createLangChainTools(weather)
const agent = createToolCallingAgent({
llm: new ChatOpenAI({ temperature: 0 }),
tools,
prompt: ChatPromptTemplate.fromMessages([
['system', 'You are a weather assistant. Be as concise as possible.'],
['placeholder', '{chat_history}'],
['human', '{input}'],
['placeholder', '{agent_scratchpad}']
])
})
const agentExecutor = new AgentExecutor({
agent,
tools,
verbose: true
})
const result = await agentExecutor.invoke({
input: 'What is the weather in San Francisco?'
})
console.log(result.output)
}
await main()

Wyświetl plik

@ -28,9 +28,12 @@
"@dexaai/dexter": "^2.0.3",
"@genkit-ai/ai": "^0.5.2",
"@genkit-ai/core": "^0.5.2",
"@langchain/core": "^0.2.5",
"@langchain/openai": "^0.1.1",
"ai": "^3.1.22",
"dotenv": "^16.4.5",
"genkitx-openai": "^0.9.0",
"langchain": "^0.2.4",
"zod": "^3.23.3"
}
}

Wyświetl plik

@ -74,6 +74,7 @@
"@dexaai/dexter": "^2.0.3",
"@fisch0920/eslint-config": "^1.3.1",
"@genkit-ai/ai": "^0.5.2",
"@langchain/core": "^0.2.5",
"@total-typescript/ts-reset": "^0.5.1",
"@types/node": "^20.12.7",
"ai": "^3.1.22",
@ -96,12 +97,20 @@
},
"peerDependencies": {
"@dexaai/dexter": "^2.0.3",
"@genkit-ai/ai": "^0.5.2",
"@langchain/core": "^0.2.5",
"ai": "^3.1.22"
},
"peerDependenciesMeta": {
"@dexaai/dexter": {
"optional": true
},
"@genkit-ai/ai": {
"optional": true
},
"@langchain/core": {
"optional": true
},
"ai": {
"optional": true
}

Wyświetl plik

@ -51,6 +51,9 @@ importers:
'@genkit-ai/ai':
specifier: ^0.5.2
version: 0.5.2
'@langchain/core':
specifier: ^0.2.5
version: 0.2.5(langchain@0.2.4(openai@4.47.3))(openai@4.47.3)
'@total-typescript/ts-reset':
specifier: ^0.5.1
version: 0.5.1
@ -123,6 +126,12 @@ importers:
'@genkit-ai/core':
specifier: ^0.5.2
version: 0.5.2
'@langchain/core':
specifier: ^0.2.5
version: 0.2.5(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))(openai@4.47.3)
'@langchain/openai':
specifier: ^0.1.1
version: 0.1.1(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))
ai:
specifier: ^3.1.22
version: 3.1.22(openai@4.47.3)(react@18.3.1)(solid-js@1.8.17)(svelte@4.2.17)(vue@3.4.27(typescript@5.4.5))(zod@3.23.8)
@ -132,6 +141,9 @@ importers:
genkitx-openai:
specifier: ^0.9.0
version: 0.9.0(@genkit-ai/ai@0.5.2)(@genkit-ai/core@0.5.2)
langchain:
specifier: ^0.2.4
version: 0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3)
zod:
specifier: ^3.23.3
version: 3.23.8
@ -425,6 +437,18 @@ packages:
'@js-sdsl/ordered-map@4.4.2':
resolution: {integrity: sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw==}
'@langchain/core@0.2.5':
resolution: {integrity: sha512-tMaKRFVewFn8crQwlbXGjT7hlMdX1yXHap1ebBx7Bb2C3C9AeZ+sXbX11m27yamypNlVVegwUcisw3YCaDkZJA==}
engines: {node: '>=18'}
'@langchain/openai@0.1.1':
resolution: {integrity: sha512-0M7GOA7+dPMQATn8UrYBUp0tWxBJjsJEdRPf+MhDD4jdK70qfC6tBbB/lrT0HchVnz5GFE7az4EUtSh8LiUgzA==}
engines: {node: '>=18'}
'@langchain/textsplitters@0.0.2':
resolution: {integrity: sha512-6bQOuYHTGYlkgPY/8M5WPq4nnXZpEysGzRopQCYjg2WLcEoIPUMMrXsAaNNdvU3BOeMrhin8izvpDPD165hX6Q==}
engines: {node: '>=18'}
'@ljharb/through@2.3.13':
resolution: {integrity: sha512-/gKJun8NNiWGZJkGzI/Ragc53cOdcLNdzjLaIa+GEjguQs0ulsurx8WN0jijdK9yPqDvziX995sMRLyLt1uZMQ==}
engines: {node: '>= 0.4'}
@ -800,9 +824,15 @@ packages:
'@types/normalize-package-data@2.4.4':
resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==}
'@types/retry@0.12.0':
resolution: {integrity: sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==}
'@types/shimmer@1.0.5':
resolution: {integrity: sha512-9Hp0ObzwwO57DpLFF0InUjUm/II8GmKAvzbefxQTihCb7KI6yc9yzf0nLc4mVdby5N4DRCgQM2wCup9KTieeww==}
'@types/uuid@9.0.8':
resolution: {integrity: sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==}
'@typescript-eslint/eslint-plugin@7.11.0':
resolution: {integrity: sha512-P+qEahbgeHW4JQ/87FuItjBj8O3MYv5gELDzr8QaQ7fsll1gSMTYb6j87MYyxwf3DtD7uGFB9ShwgmCJB5KmaQ==}
engines: {node: ^18.18.0 || >=20.0.0}
@ -1153,6 +1183,9 @@ packages:
resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==}
engines: {node: '>=8'}
binary-search@1.3.6:
resolution: {integrity: sha512-nbE1WxOTTrUWIfsfZ4aHGYu5DOuNkbxGokjV6Z2kxfJK3uaAb8zNK1muzOeipoLHZjInT4Br88BHpzevc681xA==}
bl@4.1.0:
resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==}
@ -1359,6 +1392,10 @@ packages:
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
engines: {node: '>= 0.8'}
commander@10.0.1:
resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==}
engines: {node: '>=14'}
commander@12.1.0:
resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==}
engines: {node: '>=18'}
@ -1840,6 +1877,9 @@ packages:
resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==}
engines: {node: '>=6'}
eventemitter3@4.0.7:
resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==}
eventemitter3@5.0.1:
resolution: {integrity: sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==}
@ -2259,6 +2299,9 @@ packages:
resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==}
engines: {node: '>= 0.10'}
is-any-array@2.0.1:
resolution: {integrity: sha512-UtilS7hLRu++wb/WBAw9bNuP1Eg04Ivn1vERJck8zJthEvXCBEBpGR/33u/xLKWEQf95803oalHrVDptcAvFdQ==}
is-array-buffer@3.0.4:
resolution: {integrity: sha512-wcjaerHw0ydZwfhiKbXJWLDY8A7yV7KhjQOpb83hGgGfId/aQa4TOvwyzn2PuswW2gPCYEL/nEAiSVpdOj1lXw==}
engines: {node: '>= 0.4'}
@ -2515,6 +2558,9 @@ packages:
resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==}
engines: {node: '>=10'}
js-tiktoken@1.0.12:
resolution: {integrity: sha512-L7wURW1fH9Qaext0VzaUDpFGVQgjkdE3Dgsy9/+yXyGEpBKnylTd0mU0bfbNkKDlXRb6TEsZkwuflu1B8uQbJQ==}
js-tokens@4.0.0:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
@ -2567,6 +2613,10 @@ packages:
engines: {node: ^18.0.0 || >=20.0.0}
hasBin: true
jsonpointer@5.0.1:
resolution: {integrity: sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ==}
engines: {node: '>=0.10.0'}
jsonrepair@3.8.0:
resolution: {integrity: sha512-89lrxpwp+IEcJ6kwglF0HH3Tl17J08JEpYfXnvvjdp4zV4rjSoGu2NdQHxBs7yTOk3ETjTn9du48pBy8iBqj1w==}
hasBin: true
@ -2586,6 +2636,179 @@ packages:
resolution: {integrity: sha512-QUViPXlgP6NKA57IAPff/aZSmRA6qs9wKxlEpayBorwRZG+x2LG7jD4kXh8lnH3q/gkUr64NyZ7kwErUEZJmlw==}
engines: {node: '>=18'}
langchain@0.2.4:
resolution: {integrity: sha512-zBsBuNREn/3IlWvIQqhQ2iqf6JJhyjjsB1Db/keDkcgThPI3EcblC1pqAXU2BIKHmpNUkHBR2bAUok5+xtgOcw==}
engines: {node: '>=18'}
peerDependencies:
'@aws-sdk/client-s3': ^3.310.0
'@aws-sdk/client-sagemaker-runtime': ^3.310.0
'@aws-sdk/client-sfn': ^3.310.0
'@aws-sdk/credential-provider-node': ^3.388.0
'@azure/storage-blob': ^12.15.0
'@browserbasehq/sdk': '*'
'@gomomento/sdk': ^1.51.1
'@gomomento/sdk-core': ^1.51.1
'@gomomento/sdk-web': ^1.51.1
'@mendable/firecrawl-js': ^0.0.13
'@notionhq/client': ^2.2.10
'@pinecone-database/pinecone': '*'
'@supabase/supabase-js': ^2.10.0
'@vercel/kv': ^0.2.3
'@xata.io/client': ^0.28.0
apify-client: ^2.7.1
assemblyai: ^4.0.0
axios: '*'
cheerio: ^1.0.0-rc.12
chromadb: '*'
convex: ^1.3.1
couchbase: ^4.3.0
d3-dsv: ^2.0.0
epub2: ^3.0.1
faiss-node: '*'
fast-xml-parser: '*'
handlebars: ^4.7.8
html-to-text: ^9.0.5
ignore: ^5.2.0
ioredis: ^5.3.2
jsdom: '*'
mammoth: ^1.6.0
mongodb: '>=5.2.0'
node-llama-cpp: '*'
notion-to-md: ^3.1.0
officeparser: ^4.0.4
pdf-parse: 1.1.1
peggy: ^3.0.2
playwright: ^1.32.1
puppeteer: ^19.7.2
pyodide: ^0.24.1
redis: ^4.6.4
sonix-speech-recognition: ^2.1.1
srt-parser-2: ^1.2.3
typeorm: ^0.3.12
weaviate-ts-client: '*'
web-auth-library: ^1.0.3
ws: ^8.14.2
youtube-transcript: ^1.0.6
youtubei.js: ^9.1.0
peerDependenciesMeta:
'@aws-sdk/client-s3':
optional: true
'@aws-sdk/client-sagemaker-runtime':
optional: true
'@aws-sdk/client-sfn':
optional: true
'@aws-sdk/credential-provider-node':
optional: true
'@azure/storage-blob':
optional: true
'@browserbasehq/sdk':
optional: true
'@gomomento/sdk':
optional: true
'@gomomento/sdk-core':
optional: true
'@gomomento/sdk-web':
optional: true
'@mendable/firecrawl-js':
optional: true
'@notionhq/client':
optional: true
'@pinecone-database/pinecone':
optional: true
'@supabase/supabase-js':
optional: true
'@vercel/kv':
optional: true
'@xata.io/client':
optional: true
apify-client:
optional: true
assemblyai:
optional: true
axios:
optional: true
cheerio:
optional: true
chromadb:
optional: true
convex:
optional: true
couchbase:
optional: true
d3-dsv:
optional: true
epub2:
optional: true
faiss-node:
optional: true
fast-xml-parser:
optional: true
handlebars:
optional: true
html-to-text:
optional: true
ignore:
optional: true
ioredis:
optional: true
jsdom:
optional: true
mammoth:
optional: true
mongodb:
optional: true
node-llama-cpp:
optional: true
notion-to-md:
optional: true
officeparser:
optional: true
pdf-parse:
optional: true
peggy:
optional: true
playwright:
optional: true
puppeteer:
optional: true
pyodide:
optional: true
redis:
optional: true
sonix-speech-recognition:
optional: true
srt-parser-2:
optional: true
typeorm:
optional: true
weaviate-ts-client:
optional: true
web-auth-library:
optional: true
ws:
optional: true
youtube-transcript:
optional: true
youtubei.js:
optional: true
langchainhub@0.0.11:
resolution: {integrity: sha512-WnKI4g9kU2bHQP136orXr2bcRdgz9iiTBpTN0jWt9IlScUKnJBoD0aa2HOzHURQKeQDnt2JwqVmQ6Depf5uDLQ==}
langsmith@0.1.30:
resolution: {integrity: sha512-g8f10H1iiRjCweXJjgM3Y9xl6ApCa1OThDvc0BlSDLVrGVPy1on9wT39vAzYkeadC7oG48p7gfpGlYH3kLkJ9Q==}
peerDependencies:
'@langchain/core': '*'
langchain: '*'
openai: '*'
peerDependenciesMeta:
'@langchain/core':
optional: true
langchain:
optional: true
openai:
optional: true
language-subtag-registry@0.3.23:
resolution: {integrity: sha512-0K65Lea881pHotoGEa5gDlMxt3pctLi2RplBb7Ezh4rRdLEOtgi7n4EwK9lamnUCkKBqaeKRVebTq6BAxSkpXQ==}
@ -2821,6 +3044,21 @@ packages:
resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==}
engines: {node: '>=16 || 14 >=14.17'}
ml-array-mean@1.1.6:
resolution: {integrity: sha512-MIdf7Zc8HznwIisyiJGRH9tRigg3Yf4FldW8DxKxpCCv/g5CafTw0RRu51nojVEOXuCQC7DRVVu5c7XXO/5joQ==}
ml-array-sum@1.1.6:
resolution: {integrity: sha512-29mAh2GwH7ZmiRnup4UyibQZB9+ZLyMShvt4cH4eTK+cL2oEMIZFnSyB3SS8MlsTh6q/w/yh48KmqLxmovN4Dw==}
ml-distance-euclidean@2.0.0:
resolution: {integrity: sha512-yC9/2o8QF0A3m/0IXqCTXCzz2pNEzvmcE/9HFKOZGnTjatvBbsn4lWYJkxENkA4Ug2fnYl7PXQxnPi21sgMy/Q==}
ml-distance@4.0.1:
resolution: {integrity: sha512-feZ5ziXs01zhyFUUUeZV5hwc0f5JW0Sh0ckU1koZe/wdVkJdGxcP06KNQuF0WBTj8FttQUzcvQcpcrOp/XrlEw==}
ml-tree-similarity@1.0.0:
resolution: {integrity: sha512-XJUyYqjSuUQkNQHMscr6tcjldsOoAekxADTplt40QKfwW6nd++1wHWV9AArl0Zvw/TIHgNaZZNvr8QGvE8wLRg==}
module-details-from-path@1.0.3:
resolution: {integrity: sha512-ySViT69/76t8VhE1xXHK6Ch4NcDd26gx0MzKXLO+F7NOtnqH68d9zF94nT8ZWSxXh8ELOERsnJO/sWt1xZYw5A==}
@ -2833,6 +3071,10 @@ packages:
ms@2.1.3:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
mustache@4.2.0:
resolution: {integrity: sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==}
hasBin: true
mute-stream@0.0.7:
resolution: {integrity: sha512-r65nCZhrbXXb6dXOACihYApHw2Q6pV0M3V0PSxd74N0+D8nzAdEAITq2oAjA1jVnKI+tGvEBUpqiMh0+rW6zDQ==}
@ -2932,6 +3174,10 @@ packages:
resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
num-sort@2.1.0:
resolution: {integrity: sha512-1MQz1Ed8z2yckoBeSfkQHHO9K1yDRxxtotKSJ9yvcTUUxSvfvzEq5GwBrjjHEpMlq/k5gvXdmJ1SbYxWtpNoVg==}
engines: {node: '>=8'}
number-is-nan@1.0.1:
resolution: {integrity: sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ==}
engines: {node: '>=0.10.0'}
@ -3010,6 +3256,9 @@ packages:
resolution: {integrity: sha512-470d4ibH5kizXflCzgur22GpM4nOjrg7WQ9jTOa3dNKEn248oBy4+pjOyfcFR4V4YUn/YlDNjp6h83PbviCCKQ==}
hasBin: true
openapi-types@12.1.3:
resolution: {integrity: sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw==}
optionator@0.9.4:
resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==}
engines: {node: '>= 0.8.0'}
@ -3030,6 +3279,10 @@ packages:
resolution: {integrity: sha512-mlVgR3PGuzlo0MmTdk4cXqXWlwQDLnONTAg6sm62XkMJEiRxN3GL3SffkYvqwonbkJBcrI7Uvv5Zh9yjvn2iUw==}
engines: {node: '>=12.20'}
p-finally@1.0.0:
resolution: {integrity: sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==}
engines: {node: '>=4'}
p-limit@2.3.0:
resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==}
engines: {node: '>=6'}
@ -3066,10 +3319,22 @@ packages:
resolution: {integrity: sha512-DZ/bONJILHkQ721hSr/E9wMz5Am/OTJ9P6LhLFo2Tu+jL8044tgc9LwHO8g4PiaYePnlVVRAJcKmgy8J9MVFrA==}
engines: {node: '>=14.16'}
p-queue@6.6.2:
resolution: {integrity: sha512-RwFpb72c/BhQLEXIZ5K2e+AhgNVmIejGlTgiB9MzZ0e93GRvqZ7uSi0dvRF7/XIXDeNkra2fNHBxTyPDGySpjQ==}
engines: {node: '>=8'}
p-retry@4.6.2:
resolution: {integrity: sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ==}
engines: {node: '>=8'}
p-throttle@6.1.0:
resolution: {integrity: sha512-eQMdGTxk2+047La67wefUtt0tEHh7D+C8Jl7QXoFCuIiNYeQ9zWs2AZiJdIAs72rSXZ06t11me2bgalRNdy3SQ==}
engines: {node: '>=18'}
p-timeout@3.2.0:
resolution: {integrity: sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg==}
engines: {node: '>=8'}
p-timeout@6.1.2:
resolution: {integrity: sha512-UbD77BuZ9Bc9aABo74gfXhNvzC9Tx7SxtHSh1fxvx3jTLLYvmVhiQZZrJzqqU0jKbN32kb5VOKiLEQI/3bIjgQ==}
engines: {node: '>=14.16'}
@ -3394,6 +3659,10 @@ packages:
resolution: {integrity: sha512-Hp93f349DvdEqJFHiPyzNzVjT7lDDFtQJWRotQVQNl3CHr4j7oMHStQB9UH/CJSHTrevAZXFvomgzy8lXjrK0w==}
engines: {node: '>=18'}
retry@0.13.1:
resolution: {integrity: sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==}
engines: {node: '>= 4'}
reusify@1.0.4:
resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==}
engines: {iojs: '>=1.0.0', node: '>=0.10.0'}
@ -3979,6 +4248,10 @@ packages:
resolution: {integrity: sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==}
engines: {node: '>= 0.4.0'}
uuid@9.0.1:
resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==}
hasBin: true
v8-compile-cache-lib@3.0.1:
resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==}
@ -4495,6 +4768,82 @@ snapshots:
'@js-sdsl/ordered-map@4.4.2': {}
'@langchain/core@0.2.5(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))(openai@4.47.3)':
dependencies:
ansi-styles: 5.2.0
camelcase: 6.3.0
decamelize: 1.2.0
js-tiktoken: 1.0.12
langsmith: 0.1.30(@langchain/core@0.2.5(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))(openai@4.47.3))(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))(openai@4.47.3)
ml-distance: 4.0.1
mustache: 4.2.0
p-queue: 6.6.2
p-retry: 4.6.2
uuid: 9.0.1
zod: 3.23.8
zod-to-json-schema: 3.23.0(zod@3.23.8)
transitivePeerDependencies:
- langchain
- openai
'@langchain/core@0.2.5(langchain@0.2.4(openai@4.47.3))(openai@4.47.3)':
dependencies:
ansi-styles: 5.2.0
camelcase: 6.3.0
decamelize: 1.2.0
js-tiktoken: 1.0.12
langsmith: 0.1.30(@langchain/core@0.2.5(langchain@0.2.4(openai@4.47.3))(openai@4.47.3))(langchain@0.2.4(openai@4.47.3))(openai@4.47.3)
ml-distance: 4.0.1
mustache: 4.2.0
p-queue: 6.6.2
p-retry: 4.6.2
uuid: 9.0.1
zod: 3.23.8
zod-to-json-schema: 3.23.0(zod@3.23.8)
transitivePeerDependencies:
- langchain
- openai
'@langchain/openai@0.1.1(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))':
dependencies:
'@langchain/core': 0.2.5(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))(openai@4.47.3)
js-tiktoken: 1.0.12
openai: 4.47.3
zod: 3.23.8
zod-to-json-schema: 3.23.0(zod@3.23.8)
transitivePeerDependencies:
- encoding
- langchain
'@langchain/openai@0.1.1(langchain@0.2.4(openai@4.47.3))':
dependencies:
'@langchain/core': 0.2.5(langchain@0.2.4(openai@4.47.3))(openai@4.47.3)
js-tiktoken: 1.0.12
openai: 4.47.3
zod: 3.23.8
zod-to-json-schema: 3.23.0(zod@3.23.8)
transitivePeerDependencies:
- encoding
- langchain
optional: true
'@langchain/textsplitters@0.0.2(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))(openai@4.47.3)':
dependencies:
'@langchain/core': 0.2.5(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))(openai@4.47.3)
js-tiktoken: 1.0.12
transitivePeerDependencies:
- langchain
- openai
'@langchain/textsplitters@0.0.2(langchain@0.2.4(openai@4.47.3))(openai@4.47.3)':
dependencies:
'@langchain/core': 0.2.5(langchain@0.2.4(openai@4.47.3))(openai@4.47.3)
js-tiktoken: 1.0.12
transitivePeerDependencies:
- langchain
- openai
optional: true
'@ljharb/through@2.3.13':
dependencies:
call-bind: 1.0.7
@ -4849,8 +5198,12 @@ snapshots:
'@types/normalize-package-data@2.4.4': {}
'@types/retry@0.12.0': {}
'@types/shimmer@1.0.5': {}
'@types/uuid@9.0.8': {}
'@typescript-eslint/eslint-plugin@7.11.0(@typescript-eslint/parser@7.11.0(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5)':
dependencies:
'@eslint-community/regexpp': 4.10.0
@ -5262,6 +5615,8 @@ snapshots:
binary-extensions@2.3.0: {}
binary-search@1.3.6: {}
bl@4.1.0:
dependencies:
buffer: 5.7.1
@ -5500,6 +5855,8 @@ snapshots:
dependencies:
delayed-stream: 1.0.0
commander@10.0.1: {}
commander@12.1.0: {}
commander@4.1.1: {}
@ -6091,6 +6448,8 @@ snapshots:
event-target-shim@5.0.1: {}
eventemitter3@4.0.7: {}
eventemitter3@5.0.1: {}
eventsource-parser@1.1.2: {}
@ -6599,6 +6958,8 @@ snapshots:
ipaddr.js@1.9.1: {}
is-any-array@2.0.1: {}
is-array-buffer@3.0.4:
dependencies:
call-bind: 1.0.7
@ -6805,6 +7166,10 @@ snapshots:
joycon@3.1.1: {}
js-tiktoken@1.0.12:
dependencies:
base64-js: 1.5.1
js-tokens@4.0.0: {}
js-yaml@4.1.0:
@ -6841,6 +7206,8 @@ snapshots:
chalk: 5.3.0
diff-match-patch: 1.0.5
jsonpointer@5.0.1: {}
jsonrepair@3.8.0: {}
jsx-ast-utils@3.3.5:
@ -6858,6 +7225,80 @@ snapshots:
ky@1.3.0: {}
langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3):
dependencies:
'@langchain/core': 0.2.5(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))(openai@4.47.3)
'@langchain/openai': 0.1.1(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))
'@langchain/textsplitters': 0.0.2(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))(openai@4.47.3)
binary-extensions: 2.3.0
js-tiktoken: 1.0.12
js-yaml: 4.1.0
jsonpointer: 5.0.1
langchainhub: 0.0.11
langsmith: 0.1.30(@langchain/core@0.2.5(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))(openai@4.47.3))(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))(openai@4.47.3)
ml-distance: 4.0.1
openapi-types: 12.1.3
p-retry: 4.6.2
uuid: 9.0.1
yaml: 2.4.2
zod: 3.23.8
zod-to-json-schema: 3.23.0(zod@3.23.8)
optionalDependencies:
axios: 1.7.2
ignore: 5.3.1
transitivePeerDependencies:
- encoding
- openai
langchain@0.2.4(openai@4.47.3):
dependencies:
'@langchain/core': 0.2.5(langchain@0.2.4(openai@4.47.3))(openai@4.47.3)
'@langchain/openai': 0.1.1(langchain@0.2.4(openai@4.47.3))
'@langchain/textsplitters': 0.0.2(langchain@0.2.4(openai@4.47.3))(openai@4.47.3)
binary-extensions: 2.3.0
js-tiktoken: 1.0.12
js-yaml: 4.1.0
jsonpointer: 5.0.1
langchainhub: 0.0.11
langsmith: 0.1.30(@langchain/core@0.2.5(langchain@0.2.4(openai@4.47.3))(openai@4.47.3))(langchain@0.2.4(openai@4.47.3))(openai@4.47.3)
ml-distance: 4.0.1
openapi-types: 12.1.3
p-retry: 4.6.2
uuid: 9.0.1
yaml: 2.4.2
zod: 3.23.8
zod-to-json-schema: 3.23.0(zod@3.23.8)
transitivePeerDependencies:
- encoding
- openai
optional: true
langchainhub@0.0.11: {}
langsmith@0.1.30(@langchain/core@0.2.5(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))(openai@4.47.3))(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))(openai@4.47.3):
dependencies:
'@types/uuid': 9.0.8
commander: 10.0.1
p-queue: 6.6.2
p-retry: 4.6.2
uuid: 9.0.1
optionalDependencies:
'@langchain/core': 0.2.5(langchain@0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3))(openai@4.47.3)
langchain: 0.2.4(axios@1.7.2)(ignore@5.3.1)(openai@4.47.3)
openai: 4.47.3
langsmith@0.1.30(@langchain/core@0.2.5(langchain@0.2.4(openai@4.47.3))(openai@4.47.3))(langchain@0.2.4(openai@4.47.3))(openai@4.47.3):
dependencies:
'@types/uuid': 9.0.8
commander: 10.0.1
p-queue: 6.6.2
p-retry: 4.6.2
uuid: 9.0.1
optionalDependencies:
'@langchain/core': 0.2.5(langchain@0.2.4(openai@4.47.3))(openai@4.47.3)
langchain: 0.2.4(openai@4.47.3)
openai: 4.47.3
language-subtag-registry@0.3.23: {}
language-tags@1.0.9:
@ -7098,6 +7539,27 @@ snapshots:
minipass@7.1.2: {}
ml-array-mean@1.1.6:
dependencies:
ml-array-sum: 1.1.6
ml-array-sum@1.1.6:
dependencies:
is-any-array: 2.0.1
ml-distance-euclidean@2.0.0: {}
ml-distance@4.0.1:
dependencies:
ml-array-mean: 1.1.6
ml-distance-euclidean: 2.0.0
ml-tree-similarity: 1.0.0
ml-tree-similarity@1.0.0:
dependencies:
binary-search: 1.3.6
num-sort: 2.1.0
module-details-from-path@1.0.3: {}
ms@2.0.0: {}
@ -7106,6 +7568,8 @@ snapshots:
ms@2.1.3: {}
mustache@4.2.0: {}
mute-stream@0.0.7: {}
mute-stream@0.0.8: {}
@ -7244,6 +7708,8 @@ snapshots:
dependencies:
path-key: 4.0.0
num-sort@2.1.0: {}
number-is-nan@1.0.1: {}
object-assign@4.1.1: {}
@ -7342,6 +7808,8 @@ snapshots:
transitivePeerDependencies:
- encoding
openapi-types@12.1.3: {}
optionator@0.9.4:
dependencies:
deep-is: 0.1.4
@ -7369,6 +7837,8 @@ snapshots:
p-cancelable@3.0.0: {}
p-finally@1.0.0: {}
p-limit@2.3.0:
dependencies:
p-try: 2.2.0
@ -7402,8 +7872,22 @@ snapshots:
mimic-fn: 4.0.0
type-fest: 3.13.1
p-queue@6.6.2:
dependencies:
eventemitter3: 4.0.7
p-timeout: 3.2.0
p-retry@4.6.2:
dependencies:
'@types/retry': 0.12.0
retry: 0.13.1
p-throttle@6.1.0: {}
p-timeout@3.2.0:
dependencies:
p-finally: 1.0.0
p-timeout@6.1.2: {}
p-try@2.2.0: {}
@ -7736,6 +8220,8 @@ snapshots:
onetime: 6.0.0
signal-exit: 4.1.0
retry@0.13.1: {}
reusify@1.0.4: {}
rfdc@1.3.1: {}
@ -8361,6 +8847,8 @@ snapshots:
utils-merge@1.0.1: {}
uuid@9.0.1: {}
v8-compile-cache-lib@3.0.1: {}
validate-npm-package-license@3.0.4:

Wyświetl plik

@ -35,6 +35,13 @@
- weatherapi
- wikipedia
## SDKs
- vercel ai sdk
- dexa dexter
- firebase genkit
- langchain
## TODO
- core
@ -45,16 +52,13 @@
- agentic
- walter
- sdks
- ai sdk
- dexter
- genkit
- langchain
- instructor-js
- services
- wolfram alpha
- midjourney
- unstructured
- pull from [langchain](https://github.com/langchain-ai/langchainjs/tree/main/langchain)
- provide a converter for langchain `DynamicStructuredTool`
- pull from other libs
- pull from [nango](https://docs.nango.dev/integrations/overview)

Wyświetl plik

@ -7,7 +7,7 @@ import { AIToolsProvider } from '../fns.js'
* Converts a set of Agentic stdlib AI functions to an object compatible with
* the Vercel AI SDK's `tools` parameter.
*/
export function tools(tools: AIToolsProvider | AIFunctionSet) {
export function createAISDKTools(tools: AIToolsProvider | AIFunctionSet) {
const fns = tools instanceof AIToolsProvider ? tools.functions : tools
return Object.fromEntries(

Wyświetl plik

@ -7,7 +7,7 @@ import { AIToolsProvider } from '../fns.js'
* Converts a set of Agentic stdlib AI functions to an array of Dexter-
* compatible AI functions.
*/
export function functions(input: AIToolsProvider | AIFunctionSet) {
export function createDexterFunctions(input: AIToolsProvider | AIFunctionSet) {
const fns = input instanceof AIToolsProvider ? input.functions : input
return fns.map((fn) =>

Wyświetl plik

@ -8,7 +8,7 @@ import { AIToolsProvider } from '../fns.js'
* Converts a set of Agentic stdlib AI functions to an array of Genkit-
* compatible tools.
*/
export function tools(input: AIToolsProvider | AIFunctionSet) {
export function createGenkitTools(input: AIToolsProvider | AIFunctionSet) {
const fns = input instanceof AIToolsProvider ? input.functions : input
return fns.map((fn) =>

Wyświetl plik

@ -0,0 +1,27 @@
import { DynamicStructuredTool } from '@langchain/core/tools'
import type { AIFunctionSet } from '../ai-function-set.js'
import { AIToolsProvider } from '../fns.js'
import { stringifyForModel } from '../stringify-for-model.js'
/**
* Converts a set of Agentic stdlib AI functions to an array of LangChain-
* compatible tools.
*/
export function createLangChainTools(input: AIToolsProvider | AIFunctionSet) {
const fns = input instanceof AIToolsProvider ? input.functions : input
return fns.map(
(fn) =>
new DynamicStructuredTool({
name: fn.spec.name,
description: fn.spec.description,
schema: fn.inputSchema,
func: async (input) => {
const result = await Promise.resolve(fn.impl(input))
// LangChain tools require the output to be a string
return stringifyForModel(result)
}
})
)
}