0.9.22 • Published 8 months ago

@empiricalrun/llm v0.9.22

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

llm

Package to connect and trace LLM calls.

Usage

import { LLM } from "@empiricalrun/llm";

const llm = new LLM({
  provider: "openai",
  defaultModel: "gpt-4o",
});
const llmResponse = await llm.createChatCompletion({ ... });

Vision utilities

This package also contains utilities for vision.

Query

Ask a question against the image (e.g. to extract some info, make a decision) and get the answer.

import { query } from "@empiricalrun/llm/vision";

// With Appium
const data = await driver.saveScreenshot("dummy.png");
const instruction =
  "Extract number of ATOM tokens from the image. Return only the number.";

const text = await query(data.toString("base64"), instruction);
// Example response: "0.01"

Get bounding boxes

import { getBoundingBox } from "@empiricalrun/llm/vision/bbox";

// With Appium
const data = await driver.saveScreenshot("dummy.png");
// Give a line describing the screen and then the element that you want to find
const instruction =
  "This screenshot shows a screen to send crypto tokens. What is the bounding box for the dropdown to select the token?";

const bbox = await getBoundingBox(data.toString("base64"), instruction);
const centerToTap = bbox.center; // { x: 342, y: 450 }

// **Note**: These coordinates are relative to the image dimensions, and actions like
// tap require scaling the coordinates to Appium coordinates

Bounding box can require some prompt iterations, and you can do that with a debug flag. This flag returns a base64 image that has the bounding box drawn on top of the original image.

const bbox = await getBoundingBox(data.toString("base64"), instruction, {
  debug: true,
});
console.log(bbox.annotatedImage);
0.9.21

8 months ago

0.9.22

8 months ago

0.9.16

8 months ago

0.9.18

8 months ago

0.9.19

8 months ago

0.9.20

8 months ago

0.9.14

8 months ago

0.9.15

8 months ago

0.9.13

8 months ago

0.9.12

8 months ago

0.9.9

8 months ago

0.9.10

8 months ago

0.9.11

8 months ago

0.9.6

8 months ago

0.9.5

8 months ago

0.9.4

8 months ago

0.9.3

9 months ago

0.9.2

9 months ago

0.9.1

10 months ago

0.9.0

10 months ago

0.8.3

10 months ago

0.8.2

10 months ago

0.8.1

10 months ago

0.8.0

10 months ago

0.7.4

10 months ago

0.7.3

10 months ago

0.7.2

10 months ago

0.7.1

10 months ago

0.7.0

10 months ago

0.5.0

10 months ago

0.4.5

10 months ago

0.4.4

10 months ago

0.4.3

10 months ago

0.4.2

11 months ago

0.4.1

11 months ago

0.4.0

11 months ago

0.3.0

11 months ago

0.2.0

11 months ago