From 6171d6919aae5b7a5354dd8ce856c310c58c322c Mon Sep 17 00:00:00 2001 From: Tony Holdstock-Brown Date: Fri, 22 Nov 2024 06:46:42 -0800 Subject: [PATCH] AgentKit overview --- pages/docs/agent-kit/overview.mdx | 89 ++++++++++++++++++++++++++++++ shared/Docs/navigationStructure.ts | 31 +++++++++++ 2 files changed, 120 insertions(+) create mode 100644 pages/docs/agent-kit/overview.mdx diff --git a/pages/docs/agent-kit/overview.mdx b/pages/docs/agent-kit/overview.mdx new file mode 100644 index 000000000..22cf27fc6 --- /dev/null +++ b/pages/docs/agent-kit/overview.mdx @@ -0,0 +1,89 @@ +import { Callout, GuideSelector, GuideSection, CodeGroup } from "src/shared/Docs/mdx"; +export const hidePageSidebar = true; + +# AgentKit overview + + + This page introduces the APIs and concepts to AgentKit. We recommend reading the agents and network docs in depth, +then exploring guides and best practices. + + +The AgentKit SDK lets developers build, test, and deploy reliable AI applications at scale — from single model calls to multi-agent workflows that use tools. Using the SDK lets you focus on AI code instead of technical details like orchestration, state, or infrastructure. + +Here’s how you can generate a single inference call using the SDK: + +```ts +import { Agent } from "@inngest/agent-kit"; + +export default inngest.createFunction( + { id: "summarizer" }, + { event: "api/post.created" }, + async ({ event, step }) => { + + const writer = new Agent({ + name: "writer", + system: "You are an expert writer. You write readable, concise, simple content.", + model: // TODO + }); + + const { output } = await writer.run( + "Describe the ideas behind the given input into clear topics, and explain any insight: " + + `${content}` + ); + + }, +); +``` + +And here’s how you can create a network of agents, each of which has different tools and instructions, to complete complex tasks: + +```ts +import { Network } from "@inngest/agent-kit"; +import { navigator, classifier, summarizer } from "./src/agents"; + +export default inngest.createFunction( + { id: "summarizer" }, + { event: "api/summary.requested" }, + async ({ event, step }) => { + + // Create a network of agents with separate tasks and instructions to solve + // a specific task. + const network = new Network({ + agents: [navigator, classifier, summarizer], + defaultProvider: provider, // TODO + }) + + const input = "Classify then summarize the latest 10 blog posts on https://www.deeplearning.ai/blog/" + + const result = await network.run(, ({ network }) => { + // Use an agent which figures out the specific agent to call based off of the network's history. + return defaultRoutingAgent; + }); + + }, +); +``` + +## Concepts + +It’s helpful to familiarize yourself with several concepts in order to effectively use AgentKit: + +### Agents + +An Agent is used to call a single model with a set of tools and a system prompt. When an agent runs, it calls the model passing in the prompt, user input, and any tools. Depending on the response, the agent will automatically call tools and return a standardized output. Agents can be run individually or combined into a Network of Agents which can work together to achieve more complex goals. + +### Networks + +A network is a group of agents which can work together using shared state to solve complex tasks. Networks iteratively call individual agents and their tools until the task is complete, using a router to determine the best next step. This lets you solve tasks in ways that may be hard with a single LLM request. + +### Network state + +In a network, there’s typically more than one inference call. The network stores state, which includes the *memory* of all past inference calls and a key-value store for *facts, thoughts, and observations* returned in each call. State allows you to transfer reasoning from one agent to another during *routing*, and allows you to complete complex tasks. + +### Network Routers + +A network calls different agents, many times, in a loop. The router helps determine which agent should be called next, based off of the current network state, the input, and the available agents. Examples of routers are: + +- Callback code which inspects state and returns agents (supervised networks) +- Another agent which inspects state, other available agents in the network, then returns another agent it recommends next (fully autonomous networks) +- Or a mixture of code and routing agents (semi-autonomous networks) diff --git a/shared/Docs/navigationStructure.ts b/shared/Docs/navigationStructure.ts index 046996975..93c5f6137 100644 --- a/shared/Docs/navigationStructure.ts +++ b/shared/Docs/navigationStructure.ts @@ -809,6 +809,37 @@ const sectionHome: (NavGroup | NavLink)[] = [ }, ], }, + { + title: "AgentKit", + links: [ + { + title: "AgentKit Foundations", + links: [ + { + title: "Overview", + href: "/docs/agent-kit/overview", + }, + { + title: "Getting started", + href: "/docs/agent-kit/getting-started", + }, + ], + }, + { + title: "Build with AgentKit", + links: [ + { + title: "Agents and Tools", + href: "/docs/agent-kit/ai-agents-tools", + }, + { + title: "Networks, state, and routing", + href: "/docs/agent-kit/getting-started", + }, + ], + } + ], + }, { title: "References", links: sectionReference }, { title: "",