0.0.8 • Published 8 months ago

foxtrot-ai v0.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

Usage

Install the package:

npm i foxtrot-ai

Example

Use the npm package in Javascript:

import { Crawler, SinglePromptExtractor } from 'foxtrot-ai';

const ai = 'openai:gpt-4o-mini';
const crawler = new Crawler({ ai });
const extractor = new SinglePromptExtractor({ ai });

const url = 'https://news.ycombinator.com';
const questions = [
  'what is the article title?',
  'how many points does this submission have? only number',
  'how many comments does this submission have? only number',
  'when was this article submitted? convert to YYYY-MM-DD HH:mm{am/pm} format',
];

for await (const link of crawler.stream(url, 'comment links')) {
  console.log('Extract from:', link.url);
  for await (const item of extractor.stream(link.url, questions)) {
    console.log(item);
  }
}

CLI

Or use the command line tool. Install it:

npm install -g foxtrot-ai

And then run the extract command:

foxtrot extract https://www.npmjs.com/package/@tinyhttp/cookie \
  'what is the package name?,what is the version number?,who is the main author?'

Or use npx instead:

npx foxtrot-ai extract https://www.npmjs.com/package/@tinyhttp/cookie \
  'what is the package name?,what is the version number?,who is the main author?'

cli