@empiricalrun/llm
Advanced tools
Comparing version 0.9.14 to 0.9.15
# @empiricalrun/llm | ||
## 0.9.15 | ||
### Patch Changes | ||
- 76e979c: feat: add basic cache option on point method | ||
## 0.9.14 | ||
@@ -4,0 +10,0 @@ |
import { Coordinates, Point } from "../types"; | ||
export declare function getCoordinatesFor(prompt: string, base64Image: string): Promise<Coordinates>; | ||
/** | ||
* Call the vision model to get the coordinates for a prompt. Set `useCache` to | ||
* true if you are clicking on a fixed UI element multiple times. Caching uses `prompt` | ||
* and dimensions of the `base64Image` to store the coordinates. | ||
*/ | ||
export declare function getCoordinatesFor(prompt: string, base64Image: string, options?: { | ||
useCache?: boolean; | ||
}): Promise<Coordinates>; | ||
export declare function extractTapCoordinateFromString(inputString: string): Point; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -5,7 +5,27 @@ "use strict"; | ||
const image_1 = require("../image"); | ||
const cache_1 = require("./cache"); | ||
const API_BASE_URL = process.env.VISION_MODEL_ENDPOINT; | ||
async function getCoordinatesFor(prompt, base64Image) { | ||
const llmResponse = await getLlmResponse(base64Image, prompt); | ||
const pointFromLlm = extractTapCoordinateFromString(llmResponse); | ||
const scaledPoint = scaleForImage(pointFromLlm, base64Image); | ||
/** | ||
* Call the vision model to get the coordinates for a prompt. Set `useCache` to | ||
* true if you are clicking on a fixed UI element multiple times. Caching uses `prompt` | ||
* and dimensions of the `base64Image` to store the coordinates. | ||
*/ | ||
async function getCoordinatesFor(prompt, base64Image, options) { | ||
let scaledPoint; | ||
if (options?.useCache) { | ||
const cachedPoint = (0, cache_1.getFromCache)(prompt, base64Image); | ||
if (cachedPoint) { | ||
// Cache works if prompt and image dimensions are the same | ||
console.log(`Cache hit for prompt: ${prompt}`); | ||
scaledPoint = cachedPoint; | ||
} | ||
} | ||
if (!scaledPoint) { | ||
const llmResponse = await getLlmResponse(base64Image, prompt); | ||
const pointFromLlm = extractTapCoordinateFromString(llmResponse); | ||
scaledPoint = scaleForImage(pointFromLlm, base64Image); | ||
if (options?.useCache) { | ||
(0, cache_1.setInCache)(prompt, base64Image, scaledPoint); | ||
} | ||
} | ||
const annotatedImage = await (0, image_1.drawRedDotAtPoint)(base64Image, scaledPoint); | ||
@@ -12,0 +32,0 @@ const dims = (0, image_1.dimensions)(base64Image); |
{ | ||
"name": "@empiricalrun/llm", | ||
"version": "0.9.14", | ||
"version": "0.9.15", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "exports": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7465802
57
716