Files
basically-ai-harness/agent/7-index.ts
T
Tejas Kumar eeb5f0ff9d Simplify
2026-04-02 11:06:18 +02:00

36 lines
1.0 KiB
TypeScript

import { createTools } from "./1-tools.js";
import { createContext } from "./3-context.js";
import { runLoop } from "./5-loop.js";
import { BrowserSession } from "./browser.js";
// try a shitty model
const MODEL = "openai/gpt-3.5-turbo-0613";
const TASK = `
Upvote a story on Hacker News.
Go to https://news.ycombinator.com.
Call browser_get_stories to see ranked stories with their IDs and voted status.
Find the highest-ranked story where alreadyVoted is false.
Click its upvote arrow using the exact selector: a[id="up_STORYID"] (replace STORYID with the actual id).
`.trim();
console.log(`Model: ${MODEL}`);
console.log(`Task: upvote on Hacker News\n`);
const session = new BrowserSession();
try {
await session.open();
const tools = createTools(session);
const messages = createContext(TASK);
const result = await runLoop(MODEL, messages, tools);
console.log(`\nAnswer: ${result.answer}`);
console.log(`Stopped by: ${result.stoppedBy}`);
console.log(`Iterations: ${result.iterations}`);
} finally {
await session.close();
}