chatgpt-api/readme.md

179 wiersze
6.1 KiB
Markdown
Czysty Zwykły widok Historia

2024-05-17 01:22:07 +00:00
<p align="center">
2024-06-04 12:17:55 +00:00
<a href="https://trywalter.ai"><img alt="Agentic" src="/media/agentic-header.jpg" width="308"></a>
2024-05-17 01:22:07 +00:00
</p>
<p align="center">
2024-06-04 11:30:36 +00:00
<em>AI agent stdlib that works with any AI SDK and LLM</em>
2024-05-17 01:22:07 +00:00
</p>
<p align="center">
2024-06-04 11:30:36 +00:00
<a href="https://github.com/transitive-bullshit/walter/actions/workflows/main.yml"><img alt="Build Status" src="https://github.com/transitive-bullshit/walter/actions/workflows/main.yml/badge.svg" /></a>
<a href="https://www.npmjs.com/package/@agentic/stdlib"><img alt="NPM" src="https://img.shields.io/npm/v/@agentic/stdlib.svg" /></a>
2024-05-17 01:22:07 +00:00
<a href="https://github.com/transitive-bullshit/walter/blob/main/license"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-blue" /></a>
<a href="https://prettier.io"><img alt="Prettier Code Formatting" src="https://img.shields.io/badge/code_style-prettier-brightgreen.svg" /></a>
</p>
2024-06-04 11:30:36 +00:00
# Agentic <!-- omit from toc -->
2024-05-17 01:22:07 +00:00
2024-06-04 11:30:36 +00:00
> [!WARNING]
> TODO: this project is not published yet and is an active WIP.
2024-06-03 22:09:28 +00:00
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:
```ts
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](https://github.com/vercel/ai):
```ts
// 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:
```ts
// 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.
2024-06-04 11:30:36 +00:00
All of the SDK adaptors like `createDexterFunctions` are 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')`)
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.
2024-06-03 22:09:28 +00:00
The SDK-specific imports are all isolated to keep the main `@agentic/stdlib` as lightweight as possible.
2024-06-04 11:30:36 +00:00
## Client Goals
2024-06-03 22:09:28 +00:00
- 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 use `zod` for input schema validation
2024-06-04 11:30:36 +00:00
- it should be easy to create external clients which follow the `AIFunctionsProvider` superclass / `@aiFunction` decorator pattern
2024-06-03 22:09:28 +00:00
- 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
2024-06-04 11:31:02 +00:00
- SDK adaptors should be as lightweight as possible and be optional peer dependencies of `@agentic/stdlib`
2024-06-03 22:09:28 +00:00
- SDK adatptor entrypoints should all be isolated to their own top-level imports
2024-06-04 11:31:02 +00:00
- `@agentic/stdlib/ai-sdk`
- `@agentic/stdlib/dexter`
- `@agentic/stdlib/genkit`
- `@agentic/stdlib/langchain`
2024-05-17 01:22:07 +00:00
2024-05-23 23:19:38 +00:00
## Services
2024-05-26 06:45:48 +00:00
- clearbit
- dexa
- diffbot
- exa
2024-06-03 22:09:28 +00:00
- firecrawl (WIP)
- people data labs (WIP)
2024-05-26 06:45:48 +00:00
- perigon
- predict leads
- proxycurl
2024-06-03 22:09:28 +00:00
- scraper
2024-05-26 20:41:18 +00:00
- searxng
2024-05-26 06:45:48 +00:00
- serpapi
- serper
2024-06-03 22:09:28 +00:00
- twitter (WIP)
2024-05-26 06:45:48 +00:00
- weatherapi
2024-05-26 23:11:56 +00:00
- wikipedia
2024-05-23 23:19:38 +00:00
2024-06-03 22:09:28 +00:00
## AI SDKs
2024-06-02 08:06:45 +00:00
- vercel ai sdk
- dexa dexter
- firebase genkit
- langchain
2024-05-23 23:19:38 +00:00
## TODO
2024-06-02 22:30:39 +00:00
- rename this repo to agentic
- change license to MIT
2024-06-02 07:30:50 +00:00
- sdks
- instructor-js
2024-06-02 22:30:39 +00:00
- TODO
2024-05-23 23:19:38 +00:00
- services
2024-06-03 06:19:10 +00:00
- e2b
- search-and-scrape
- replicate
- huggingface
2024-05-26 20:41:18 +00:00
- wolfram alpha
2024-05-26 06:45:48 +00:00
- midjourney
- unstructured
2024-05-23 23:19:38 +00:00
- pull from [langchain](https://github.com/langchain-ai/langchainjs/tree/main/langchain)
2024-06-02 08:06:45 +00:00
- provide a converter for langchain `DynamicStructuredTool`
2024-05-23 23:19:38 +00:00
- pull from other libs
- pull from [nango](https://docs.nango.dev/integrations/overview)
2024-06-04 12:17:55 +00:00
- tools
- calculator
2024-06-03 22:09:28 +00:00
- tools / chains / flows / runnables
- market maps
2024-06-03 17:26:46 +00:00
- https://github.com/causaly/zod-validation-error
2024-05-23 23:19:38 +00:00
2024-05-17 01:22:07 +00:00
## License
2024-06-04 11:30:36 +00:00
MIT © [Travis Fischer](https://twitter.com/transitive_bs)
2024-05-17 01:22:07 +00:00
To stay up to date or learn more, follow [@transitive_bs](https://twitter.com/transitive_bs) on Twitter.