52fe2db156 | ||
---|---|---|
.github | ||
.husky | ||
bin | ||
examples | ||
media | ||
src | ||
.editorconfig | ||
.env.example | ||
.eslintrc.json | ||
.gitignore | ||
.npmrc | ||
.prettierrc | ||
json-schema.json | ||
license | ||
package.json | ||
pnpm-lock.yaml | ||
pnpm-workspace.yaml | ||
readme.md | ||
tsconfig.json | ||
tsup.config.ts | ||
vite.config.ts |
readme.md
AI agent stdlib that works with any AI SDK and LLM
Agentic
[!WARNING]
TODO: this project is not published yet and is an active WIP.
The goal of this project is to create a set of standard AI functions / tools which are optimized for both normal TS-usage as well as LLM-based usage across any popular AI SDK via simple adaptors.
For example, all of the stdlib tools like WeatherClient
can be used both as normal, fully-typed TS SDKs:
import { WeatherClient } from '@agentic/stdlib'
const weather = new WeatherClient() // (requires `WEATHER_API_KEY` env var)
const result = await clearbit.getCurrentWeather({
q: 'San Francisco'
})
console.log(result)
Or you can use them as a set of LLM-based functions / tools using adaptors specific to each LLM SDK. This example uses Vercel's AI SDK:
// sdk-specific imports
import { openai } from '@ai-sdk/openai'
import { generateText } from 'ai'
import { createAISDKTools } from '@agentic/stdlib/ai-sdk'
// sdk-agnostic imports
import { WeatherClient } from '@agentic/stdlib'
const weather = new WeatherClient()
const result = await generateText({
model: openai('gpt-4o'),
tools: createAISDKTools(weather),
toolChoice: 'required',
prompt: 'What is the weather in San Francisco?'
})
console.log(result.toolResults[0])
Let's take a slightly more complicated example which uses multiple clients and selects a subset of their functions using the pick
method:
// sdk-specific imports
import { ChatModel, createAIRunner } from '@dexaai/dexter'
import { createDexterFunctions } from '@agentic/stdlib/dexter'
// sdk-agnostic imports
import { PerigonClient, SerperClient } from '@agentic/stdlib'
async function main() {
const perigon = new PerigonClient()
const serper = new SerperClient()
const runner = createAIRunner({
chatModel: new ChatModel({
params: { model: 'gpt-4o', temperature: 0 }
}),
functions: createDexterFunctions(
perigon.functions.pick('search_news_stories'),
serper
),
systemMessage:
'You are a helpful assistant. Be as concise as possible. Respond in markdown. Always cite your sources.'
})
const result = await runner(
'Summarize the latest news stories about the upcoming US election.'
)
console.log(result)
}
Here we've exposed 2 functions to the LLM, search_news_stories
which corresponds to the PerigonClient.searchStories
method and serper_google_search
via the SerperClient.search
method.
All of the SDK adaptors like createDexterFunctions
are very flexible in what they accept. AIFunctionLike
objects include:
AIFunctionSet
- Sets of AI functions (likeperigon.functions.pick('search_news_stories')
orperigon.functions
orserper.functions
)AIFunctionsProvider
- Client classes which expose anAIFunctionSet
via the.functions
property (likeperigon
orserper
)AIFunction
- Individual functions (likeperigon.functions.get('search_news_stories')
orserper.functions.get('serper_google_search')
)
You can pass as many or as few of these AIFunctionLike
objects as you'd like and you can manipulate them as AIFunctionSet
objects via .pick
, .omit
, .get
, .map
, etc.
The SDK-specific imports are all isolated to keep the main @agentic/stdlib
as lightweight as possible.
Client Goals
- clients should be as minimal as possible
- clients must use
ky
as a lightweight native fetch wrapper - clients must have a strongly-typed TS DX
- clients should expose select methods via the
@aiFunction(...)
decorator@aiFunction
methods must usezod
for input schema validation
- it should be easy to create external clients which follow the
AIFunctionsProvider
superclass /@aiFunction
decorator pattern - common utility functions for LLM-based function calling should be exported for convenience
- clients and AIFunctions should be composable via
AIFunctionSet
- clients must work with all major TS AI SDKs
- SDK adaptors should be as lightweight as possible and be optional peer dependencies of
@agentic/core
- SDK adatptor entrypoints should all be isolated to their own top-level imports
@agentic/core/ai-sdk
@agentic/core/dexter
@agentic/core/genkit
@agentic/core/langchain
- SDK adaptors should be as lightweight as possible and be optional peer dependencies of
Services
- clearbit
- dexa
- diffbot
- exa
- firecrawl (WIP)
- people data labs (WIP)
- perigon
- predict leads
- proxycurl
- scraper
- searxng
- serpapi
- serper
- twitter (WIP)
- weatherapi
- wikipedia
AI SDKs
- vercel ai sdk
- dexa dexter
- firebase genkit
- langchain
TODO
- rename this repo to agentic
- change license to MIT
- sdks
- instructor-js
- TODO
- services
- tools / chains / flows / runnables
- market maps
- https://github.com/causaly/zod-validation-error
License
MIT © Travis Fischer
To stay up to date or learn more, follow @transitive_bs on Twitter.