-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { Callout, GuideSelector, GuideSection, CodeGroup } from "src/shared/Docs/mdx"; | ||
export const hidePageSidebar = true; | ||
|
||
# AgentKit overview | ||
|
||
<Callout variant="info"> | ||
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. | ||
</Callout> | ||
|
||
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>${content}</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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters