kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
pull/704/head
rodzic
764a52690a
commit
7b05be94ed
|
@ -3,6 +3,10 @@ title: Intro
|
|||
description: Agentic is an open source, TypeScript, AI agent standard library that works with any LLM and TS AI SDK.
|
||||
---
|
||||
|
||||
<Frame style={{ maxWidth: 308, margin: '0 auto' }}>
|
||||
<img src='/media/agentic-header.jpg' alt='Agentic header' />
|
||||
</Frame>
|
||||
|
||||
Agentic's standard library of TypeScript AI tools are **optimized for both TS-usage as well as LLM-based usage**, which is really important for testing and debugging.
|
||||
|
||||
Agentic tools work with any LLM capable of function calling and all of the major TS AI SDKs, including:
|
||||
|
@ -14,7 +18,15 @@ Agentic tools work with any LLM capable of function calling and all of the major
|
|||
- Mastra
|
||||
- Firebase Genkit
|
||||
- Dexa Dexter
|
||||
- xsAI
|
||||
|
||||
<Frame style={{ maxWidth: 308, margin: '0 auto' }}>
|
||||
<img src='/media/agentic-header.jpg' alt='Agentic header' />
|
||||
</Frame>
|
||||
## Features
|
||||
|
||||
✅ Thoroughly tested, production-ready AI tools
|
||||
✅ Tools work across all leading TS AI SDKs
|
||||
✅ Tools are hand-coded and extremely minimal
|
||||
✅ Tools have both a good manual DX and LLM DX via the `@aiFunction` decorator
|
||||
✅ Tools use native `fetch`
|
||||
✅ Tools use `ky` to wrap `fetch`, so HTTP options, throttling, retries, etc are easy to customize
|
||||
✅ Supports tools from any MCP server ([createMcpTools](/tools/mcp))
|
||||
✅ Generate new Agentic tool clients from OpenAPI specs ([@agentic/openapi-to-ts](https://github.com/transitive-bullshit/agentic/tree/main/packages/openapi-to-ts))
|
||||
|
|
|
@ -78,8 +78,52 @@ You must provide either an existing `transport`, an existing `serverUrl`, or a
|
|||
|
||||
All tools within the `McpTools` instance will be namespaced under the given `name`.
|
||||
|
||||
`createMcpTools` takes in the following options ([source](https://github.com/transitive-bullshit/agentic/blob/main/packages/mcp/src/types.ts)):
|
||||
|
||||
```ts
|
||||
export interface McpToolsOptions {
|
||||
/**
|
||||
* Provide a name for this client which will be its namespace for all tools and prompts.
|
||||
*/
|
||||
name: string
|
||||
|
||||
/**
|
||||
* Provide a version number for this client (defaults to 1.0.0).
|
||||
*/
|
||||
version?: string
|
||||
|
||||
/**
|
||||
* If you already have an MCP transport you'd like to use, pass it here to connect to the server.
|
||||
*/
|
||||
transport?: Transport
|
||||
|
||||
/**
|
||||
* Start a local server process using the stdio MCP transport.
|
||||
*/
|
||||
serverProcess?: StdioServerParameters
|
||||
|
||||
/**
|
||||
* Connect to a remote server process using the SSE MCP transport.
|
||||
*/
|
||||
serverUrl?: string
|
||||
|
||||
/**
|
||||
* Return tool responses in raw MCP form instead of processing them for Genkit compatibility.
|
||||
*/
|
||||
rawToolResponses?: boolean
|
||||
|
||||
/**
|
||||
* An optional filter function to determine which tools should be enabled.
|
||||
*
|
||||
* By default, all tools available on the MCP server will be enabled, but you
|
||||
* can use this to filter a subset of those tools.
|
||||
*/
|
||||
toolsFilter?: McpToolsFilter
|
||||
}
|
||||
```
|
||||
|
||||
### JSON Schema
|
||||
|
||||
Note that `McpTools` uses JSON Schemas for toll input parameters, whereas most built-in tools use Zod schemas. This is important because some AI frameworks don't support JSON Schemas.
|
||||
Note that `McpTools` uses JSON Schemas for toll input parameters, whereas most built-in tools use Zod schemas. This is important because some AI frameworks don't support JSON Schemas as AI function parameters.
|
||||
|
||||
Currently, Mastra, Dexter, and xsAI don't support JSON Schema input parameters, so they won't work with `McpTools`.
|
||||
Currently, Mastra, Dexter, and xsAI don't support JSON Schema input parameters, so they won't work with `McpTools`. All of the other AI SDKs should work fine with the JSON Schema-based tools.
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
import { Client as McpClient } from '@modelcontextprotocol/sdk/client/index.js'
|
||||
import { type z } from 'zod'
|
||||
|
||||
import type { McpClientOptions, McpToolsFilter } from './types'
|
||||
import type { McpToolsFilter, McpToolsOptions } from './types'
|
||||
import { paginate } from './paginate'
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@ export class McpTools extends AIFunctionsProvider {
|
|||
rawToolResponses = false
|
||||
}: {
|
||||
client: McpClient
|
||||
} & McpClientOptions) {
|
||||
} & McpToolsOptions) {
|
||||
super()
|
||||
|
||||
this.name = name
|
||||
|
@ -136,7 +136,7 @@ export class McpTools extends AIFunctionsProvider {
|
|||
* All tools within the `McpTools` instance will be namespaced under the given
|
||||
* `name`.
|
||||
*/
|
||||
static async fromMcpClient(params: { client: McpClient } & McpClientOptions) {
|
||||
static async fromMcpClient(params: { client: McpClient } & McpToolsOptions) {
|
||||
const mcpTools = new McpTools(params)
|
||||
await mcpTools._init()
|
||||
return mcpTools
|
||||
|
@ -152,7 +152,7 @@ export class McpTools extends AIFunctionsProvider {
|
|||
* `name`.
|
||||
*/
|
||||
export async function createMcpTools(
|
||||
params: McpClientOptions
|
||||
params: McpToolsOptions
|
||||
): Promise<McpTools> {
|
||||
const transport = await createMcpTransport(params)
|
||||
const client = new McpClient(
|
||||
|
@ -169,7 +169,7 @@ export async function createMcpTools(
|
|||
* `serverUrl`, or a `serverProcess` to spawn.
|
||||
*/
|
||||
export async function createMcpTransport(
|
||||
params: McpClientOptions
|
||||
params: McpToolsOptions
|
||||
): Promise<Transport> {
|
||||
if (params.transport) return params.transport
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js'
|
|||
|
||||
export type McpToolsFilter = (toolName: string) => boolean
|
||||
|
||||
export interface McpClientOptions {
|
||||
export interface McpToolsOptions {
|
||||
/**
|
||||
* Provide a name for this client which will be its namespace for all tools and prompts.
|
||||
*/
|
||||
|
|
24
readme.md
24
readme.md
|
@ -19,6 +19,7 @@
|
|||
|
||||
- [Intro](#intro)
|
||||
- [Under the hood](#under-the-hood)
|
||||
- [Features](#features)
|
||||
- [Docs](#docs)
|
||||
- [AI SDKs](#ai-sdks)
|
||||
- [Vercel AI SDK](#vercel-ai-sdk)
|
||||
|
@ -52,7 +53,7 @@ const result = await weather.getCurrentWeather({
|
|||
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.
|
||||
Or you can use these clients as **LLM-based tools**.
|
||||
|
||||
This works across all the leading AI SDKs via adapters. Here's an example using [Vercel's AI SDK](https://github.com/vercel/ai):
|
||||
|
||||
|
@ -80,7 +81,7 @@ 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!
|
||||
|
||||
All Agentic clients expose an `AIFunctionSet`, which makes it easy to mix & match all sorts of different tools together.
|
||||
All Agentic clients expose an `AIFunctionSet`, which makes it easy to mix & match different tools together.
|
||||
|
||||
```ts
|
||||
import { SerperClient, WikipediaClient, FirecrawlClient } from '@agentic/stdlib'
|
||||
|
@ -91,6 +92,8 @@ const firecrawl = new FirecrawlClient()
|
|||
|
||||
const result = await generateText({
|
||||
model: openai('gpt-4o-mini'),
|
||||
// This example uses tools from 3 different sources. You can pass as many
|
||||
// sources as you want.
|
||||
tools: createAISDKTools(
|
||||
googleSearch,
|
||||
wikipedia,
|
||||
|
@ -99,7 +102,7 @@ const result = await generateText({
|
|||
),
|
||||
toolChoice: 'required',
|
||||
prompt:
|
||||
'What year did Jurassic Park come out, and what else happened that year?'
|
||||
'What year did Jurassic Park the movie come out, and what else happened that year?'
|
||||
})
|
||||
```
|
||||
|
||||
|
@ -107,7 +110,18 @@ const result = await generateText({
|
|||
|
||||
All of the adapters (like `createAISDKTools`) accept a very flexible var args of `AIFunctionLike` parameters, so you can pass as many tools as you'd like. An `AIFunctionLike` can be any agentic client instance, a single `AIFunction` selected from the client's `.functions` property (which holds an `AIFunctionSet` of available AI functions), or an AI function created manually via `createAIFunction`.
|
||||
|
||||
`AIFunctionLike` and `AIFunctionSet` are details that you likely won't have to touch directly, but they're important because of their flexibility.
|
||||
`AIFunctionLike` and `AIFunctionSet` are implementation details that you likely won't have to touch directly, but they're important because of their flexibility.
|
||||
|
||||
## Features
|
||||
|
||||
✅ Thoroughly tested, production-ready AI tools
|
||||
✅ Tools work across all leading TS AI SDKs
|
||||
✅ Tools are hand-coded and extremely minimal
|
||||
✅ Tools have both a good manual DX and LLM DX via the `@aiFunction` decorator
|
||||
✅ Tools use native `fetch`
|
||||
✅ Tools use `ky` to wrap `fetch`, so HTTP options, throttling, retries, etc are easy to customize
|
||||
✅ Supports tools from any MCP server ([createMcpTools(...)](https://agentic.so/tools/mcp))
|
||||
✅ Generate new Agentic tool clients from OpenAPI specs ([@agentic/openapi-to-ts](./packages/openapi-to-ts))
|
||||
|
||||
## Docs
|
||||
|
||||
|
@ -198,7 +212,7 @@ Full docs are available at [agentic.so](https://agentic.so).
|
|||
> All Agentic clients have been hand-crafted for minimal size, with very few relying on external dependencies aside from our native `fetch` wrapper, [ky](https://github.com/sindresorhus/ky).
|
||||
|
||||
> [!NOTE]
|
||||
> Missing a tool or want to add your own tool to this list? If you have an OpenAPI v3 spec for your API, we make it extremely easy to add support using our [@agentic/openapi-to-ts CLI](./packages/openapi-to-ts). Otherwise, feel free to [open an issue to discuss](https://github.com/transitive-bullshit/agentic/issues/new?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen).
|
||||
> Missing a tool or want to add your own tool to this list? If you have an OpenAPI v3 spec for your tool's API, we make it extremely easy to add support using our [@agentic/openapi-to-ts CLI](./packages/openapi-to-ts). Otherwise, feel free to [open an issue to discuss](https://github.com/transitive-bullshit/agentic/issues/new?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen).
|
||||
|
||||
For more details, see the [docs](https://agentic.so).
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue