Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/transitive-bullshit/chatgpt-api

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/transitive-bullshit/chatgpt-api

  • v6.6.1+incompatible
  • Source
  • Go
  • Socket score

Version published
Created
Source

Agentic

AI agent stdlib that works with any LLM and TypeScript AI SDK.

Build Status NPM MIT License Prettier Code Formatting

Agentic

Intro

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 apps and that work with all of the major AI SDKs (LangChain, LlamaIndex, Vercel AI SDK, OpenAI SDK, etc).

For example, stdlib clients like WeatherClient can be used as normal TS classes:

import { WeatherClient } from '@agentic/stdlib'

const weather = new WeatherClient() // (requires `WEATHER_API_KEY` env var)

const result = await weather.getCurrentWeather({
  q: 'San Francisco'
})
console.log(result)

Or you can use these clients as LLM-based tools where the LLM decides when and how to invoke the underlying functions for you.

This works across all of the major AI SDKs via adaptors. Here's an example using 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'),
  // this is the key line which uses the `@agentic/stdlib/ai-sdk` adaptor
  tools: createAISDKTools(weather),
  toolChoice: 'required',
  prompt: 'What is the weather in San Francisco?'
})

console.log(result.toolResults[0])

You can use our standard library of thoroughly tested AI functions with your favorite AI SDK – without having to write any glue code!

Here's a slightly more complex example which uses multiple clients and selects a subset of their functions using the AIFunctionSet.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() {
  // Perigon is a news API and Serper is a Google search API
  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.`
  })

  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 comes from the PerigonClient.searchStories method) and serper_google_search (which implicitly comes from the SerperClient.search method).

All of the SDK adaptors like createDexterFunctions accept very flexible in what they accept. AIFunctionLike objects include:

  • AIFunctionSet - Sets of AI functions (like perigon.functions.pick('search_news_stories') or perigon.functions or serper.functions)
  • AIFunctionsProvider - Client classes which expose an AIFunctionSet via the .functions property (like perigon or serper)
  • AIFunction - Individual functions (like perigon.functions.get('search_news_stories') or serper.functions.get('serper_google_search') or AI functions created directly via the createAIFunction utility function)

You can pass as many of these AIFunctionLike objects as you'd like and you can manipulate them as AIFunctionSet sets via .pick, .omit, .get, .map, etc.

Install

npm install @agentic/stdlib

This package is ESM only and requires Node.js >= 18 or an equivalent environment (bun, deno, CF workers, etc).

[!NOTE] All heavy third-party imports are isolated as optional peer dependencies to keep the main @agentic/stdlib package as lightweight as possible.

Depending on the AI SDK and tool you want to use, you'll also need to install the required peer dependencies.

Services

ServiceClientDescription
BingBingClientBing web search.
CalculatorcalculatorBasic calculator for simple mathematical expressions.
ClearbitClearbitClientResolving and enriching people and company datae.
DexaDexaClientAnswers questions from the world's best podcasters.
DiffbotDiffbotClientWeb page classification and scraping; person and company data enrichment.
E2Be2bHosted Python code intrepreter sandbox which is really useful for data analysis, flexible code execution, and advanced reasoning on-the-fly.
ExaExaClientWeb search tailored for LLMs.
FirecrawlFirecrawlClientWebsite scraping and sanitization.
HackerNewsHackerNewsClientOfficial HackerNews API.
HunterHunterClientEmail finder, verifier, and enrichment.
JinaJinaClientClean URL reader and web search + URL top result reading with a generous free tier.
MidjourneyMidjourneyClientUnofficial Midjourney client for generative images.
NovuNovuClientSending notifications (email, SMS, in-app, push, etc).
People Data LabsPeopleDataLabsClientPeople & company data (WIP).
PerigonPerigonClientReal-time news API and web content data from 140,000+ sources. Structured and enriched by AI, primed for LLMs.
PolygonPolygonClientStock market and company financial data.
PredictLeadsPredictLeadsClientIn-depth company data including signals like fundraising events, hiring news, product launches, technologies used, etc.
ProxycurlProxycurlClientPeople and company data from LinkedIn & Crunchbase.
ScraperScraperClientScrapes URLs into clean html/markdown/text content (TODO: currently closed beta).
SearxngSearxngClientOSS meta search engine capable of searching across many providers like Reddit, Google, Brave, Arxiv, Genius, IMDB, Rotten Tomatoes, Wikidata, Wolfram Alpha, YouTube, GitHub, etc.
SerpAPISerpAPIClientLightweight wrapper around SerpAPI for Google search.
SerperSerperClientLightweight wrapper around Serper for Google search.
SlackSlackClientSend and receive Slack messages.
SocialDataSocialDataClientUnofficial Twitter / X client (readonly) which is much cheaper than the official Twitter API.
TavilyTavilyClientWeb search API tailored for LLMs.
TwilioTwilioClientTwilio conversation API to send and receive SMS messages.
TwitterTwitterClientBasic Twitter API methods for fetching users, tweets, and searching recent tweets. Includes support for plan-aware rate-limiting. Uses Nango for OAuth support.
WeatherAPIWeatherClientBasic access to current weather data based on location.
WikidataWikidataClientBasic Wikidata client.
WikipediaWikipediaClientWikipedia page search and summaries.
Wolfram AlphaWolframAlphaClientWolfram Alpha LLM API client for answering computational, mathematical, and scientific questions.

Note that many of these clients expose multiple AI functions.

Compound Tools

  • SearchAndCrawl

AI SDKs

  • OpenAI SDK
    • no need for an adaptor; use AIFunctionSet.specs or AIFunctionSet.toolSpecs
  • Vercel AI SDK
    • import { createAISDKTools } from '@agentic/stdlib/ai-sdk'
  • LangChain
    • import { createLangChainTools } from '@agentic/stdlib/langchain'
  • LlamaIndex
    • import { createLlamaIndexTools } from '@agentic/stdlib/llamaindex'
  • Firebase Genkit
    • import { createGenkitTools } from '@agentic/stdlib/genkit'
  • Dexa Dexter
    • import { createDexterFunctions } from '@agentic/stdlib/dexter'

See the examples directory for examples of how to use each of these adaptors.

Client Goals

  • clients should be as minimal as possible
  • clients should use ky and zod where possible
  • clients should have a strongly-typed TS DX
  • clients should expose select methods via the @aiFunction(...) decorator
    • inputSchema zod schemas should be as minimal as possible with descriptions prompt engineered specifically for use with LLMs
  • clients and AIFunctions should be composable via AIFunctionSet
  • clients should work with all major TS AI SDKs
    • SDK adaptors should be as lightweight as possible and be optional peer dependencies of @agentic/stdlib

TODO

Contributors

License

MIT © Travis Fischer

To stay up to date or learn more, follow @transitive_bs on Twitter.

FAQs

Package last updated on 03 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc