Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent() tool calling loop + Network() ReAct impl. #17

Merged
merged 15 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
25 changes: 12 additions & 13 deletions demo/inngest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import {
anthropic,
createAgent,
createNetwork,
createTypedTool,
createTool,
defaultRoutingAgent,
openai,
} from "../src/index";
import { EventSchemas, Inngest } from "inngest";
import { z } from "zod";
Expand All @@ -24,17 +25,16 @@ export const fn = inngest.createFunction(
{ id: "agent" },
{ event: "agent/run" },
async ({ event, step }) => {
const model = anthropic({ model: "claude-3-5-haiku-latest", max_tokens: 1024, step });
const model = openai({ model: "gpt-4", step });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporary, for the sake of local testing and iterations


// 1. Single agents
//
// 1. Single agent

// Run a single agent as a prompt without a network.
const { output, raw } = await codeWritingAgent.run(event.data.input, {
await codeWritingAgent.run(event.data.input, {
model,
});

// 2. A network of agents that works together

// 2. A network of agents that works together
const network = createNetwork({
agents: [
codeWritingAgent.withModel(model),
Expand All @@ -61,8 +61,7 @@ export const fn = inngest.createFunction(
);

const systemPrompt =
"You are an expert TypeScript programmer. Given a set of asks, think step-by-step to plan clean, " +
"idiomatic TypeScript code, with comments and tests as necessary.";
"You are an expert TypeScript programmer. You can create files with idiomatic TypeScript code, with comments and associated tests.";

const codeWritingAgent = createAgent({
name: "Code writer",
Expand Down Expand Up @@ -99,9 +98,9 @@ const codeWritingAgent = createAgent({
// "Do not respond with anything else other than the following XML tags:" +
// "- If you would like to write code, add all code within the following tags (replace $filename and $contents appropriately):" +
// " <file name='$filename.ts'>$contents</file>";
createTypedTool({
name: "write_files",
description: "Write code with the given filenames",
createTool({
name: "create_files",
description: "Create files with the given filenames and contents",
parameters: z
.object({
files: z.array(
Expand Down Expand Up @@ -141,7 +140,7 @@ const executingAgent = createAgent({
},
},

system: `You are an export TypeScript engineer that can execute commands, run tests, debug the output, and make modifications to code.
system: `You are an expert TypeScript engineer that can execute commands, run tests, debug the output, and make modifications to code.

Think carefully about the request that the user is asking for. Do not respond with anything else other than the following XML tags:

Expand Down
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dependencies": {
"@inngest/agent-kit": "~0.0.1",
"express": "^4.21.1",
"inngest": "^3.26.2"
"inngest": "^3.27.3"
},
"devDependencies": {
"@types/express": "^5.0.0",
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"build": "rm -rf dist && tsc",
"lint": "eslint .",
"release": "pnpm run build && changeset publish",
"prepare": "husky install"
"prepare": "husky install",
"dev": "nodemon --watch demo -e ts --exec \"ts-node -P tsconfig-demo.json demo/index.ts\""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporary crap to make the demo work with the local AgentKit library

},
"files": [
"dist"
Expand Down Expand Up @@ -38,14 +39,16 @@
}
},
"dependencies": {
"inngest": "3.27.1",
"inngest": "^3.27.4",
"express": "^4.21.1",
"openai-zod-to-json-schema": "^1.0.3",
"zod": "^3.23.8"
},
"packageManager": "pnpm@9.14.2",
"devDependencies": {
"@changesets/cli": "^2.27.10",
"@eslint/js": "^9.15.0",
"@types/express": "^5.0.0",
"@types/node": "^22.9.1",
"@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0",
Expand All @@ -54,7 +57,9 @@
"eslint-plugin-prettier": "^5.2.1",
"husky": ">=7",
"lint-staged": ">=10",
"nodemon": "^3.0.2",
"prettier": "^3.3.3",
"ts-node": "^10.9.2",
"typescript": "^5.6.3",
"typescript-eslint": "^8.15.0"
},
Expand Down
Loading
Loading