-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
26 lines (23 loc) · 807 Bytes
/
index.ts
File metadata and controls
26 lines (23 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { stepCountIs, streamText } from "ai";
import { google } from "@ai-sdk/google";
import { SYSTEM_PROMPT } from "./prompts";
import { getFileChangesInDirectoryTool } from "./tools";
const codeReviewAgent = async (prompt: string) => {
const result = streamText({
model: google("models/gemini-2.5-flash"),
prompt,
system: SYSTEM_PROMPT,
tools: {
getFileChangesInDirectoryTool: getFileChangesInDirectoryTool,
},
stopWhen: stepCountIs(10),
});
for await (const chunk of result.textStream) {
process.stdout.write(chunk);
}
};
// === TOOL CALL ===
// Specify which directory the code review agent should review changes in your prompt
await codeReviewAgent(
"Review the code changes in '../my-agent' directory, make your reviews and suggestions file by file",
);