Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

autoevals

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autoevals - npm Package Compare versions

Comparing version 0.0.32 to 0.0.33

.turbo/turbo-build.log

106

jsdist/bundle.js

@@ -46,30 +46,9 @@ var __defProp = Object.defineProperty;

// js/util.ts
var NoopSpan = class {
constructor() {
this.kind = "span";
this.id = "";
this.span_id = "";
this.root_span_id = "";
}
log(_) {
}
startSpan(_0, _1) {
return this;
}
traced(_0, callback, _1) {
return callback(this);
}
end(args) {
var _a;
return (_a = args == null ? void 0 : args.endTime) != null ? _a : (/* @__PURE__ */ new Date()).getTime() / 1e3;
}
close(args) {
return this.end(args);
}
};
function currentSpan() {
function currentSpanTraced(name, callback, args) {
if (globalThis.__inherited_braintrust_state) {
return globalThis.__inherited_braintrust_state.currentSpan.getStore();
const currentSpan = globalThis.__inherited_braintrust_state.currentSpan.getStore();
return currentSpan.traced(name, (span) => callback(span.log), args);
} else {
return new NoopSpan();
return callback(() => {
});
}

@@ -82,36 +61,39 @@ }

const { cache, openAiApiKey, openAiOrganizationId, openAiBaseUrl } = options;
return await currentSpan().traced("OpenAI Completion", async (span) => {
var _b, _c, _d;
let cached = false;
let ret = await (cache == null ? void 0 : cache.get(params));
if (ret) {
cached = true;
} else {
const openai = new OpenAI({
apiKey: openAiApiKey || Env.OPENAI_API_KEY,
organization: openAiOrganizationId,
baseURL: openAiBaseUrl || PROXY_URL
return await currentSpanTraced(
"OpenAI Completion",
async (spanLog) => {
var _b, _c, _d;
let cached = false;
let ret = await (cache == null ? void 0 : cache.get(params));
if (ret) {
cached = true;
} else {
const openai = new OpenAI({
apiKey: openAiApiKey || Env.OPENAI_API_KEY,
organization: openAiOrganizationId,
baseURL: openAiBaseUrl || PROXY_URL
});
if (openai === null) {
throw new Error("OPENAI_API_KEY not set");
}
const completion = await openai.chat.completions.create(params);
await (cache == null ? void 0 : cache.set(params, completion));
ret = completion;
}
const _a = params, { messages } = _a, rest = __objRest(_a, ["messages"]);
spanLog({
input: messages,
metadata: __spreadProps(__spreadValues({}, rest), {
cached
}),
output: ret.choices[0],
metrics: {
tokens: (_b = ret.usage) == null ? void 0 : _b.total_tokens,
prompt_tokens: (_c = ret.usage) == null ? void 0 : _c.prompt_tokens,
completion_tokens: (_d = ret.usage) == null ? void 0 : _d.completion_tokens
}
});
if (openai === null) {
throw new Error("OPENAI_API_KEY not set");
}
const completion = await openai.chat.completions.create(params);
await (cache == null ? void 0 : cache.set(params, completion));
ret = completion;
return ret;
}
const _a = params, { messages } = _a, rest = __objRest(_a, ["messages"]);
span.log({
input: messages,
metadata: __spreadProps(__spreadValues({}, rest), {
cached
}),
output: ret.choices[0],
metrics: {
tokens: (_b = ret.usage) == null ? void 0 : _b.total_tokens,
prompt_tokens: (_c = ret.usage) == null ? void 0 : _c.prompt_tokens,
completion_tokens: (_d = ret.usage) == null ? void 0 : _d.completion_tokens
}
});
return ret;
});
);
}

@@ -309,4 +291,2 @@

}));
let ret = null;
let validityScore = 1;
try {

@@ -328,3 +308,3 @@ const resp = await cachedChatCompletion(

if (resp.choices.length > 0) {
ret = __spreadValues({
return __spreadValues({
name

@@ -336,4 +316,3 @@ }, parseResponse(resp.choices[0].message, choiceScores));

} catch (error) {
validityScore = 0;
ret = {
return {
name,

@@ -344,3 +323,2 @@ score: 0,

}
return ret;
}

@@ -347,0 +325,0 @@ function parseResponse(resp, choiceScores) {

@@ -80,4 +80,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

const messages = messagesArg.map((m) => (Object.assign(Object.assign({}, m), { content: m.content && mustache.render(m.content, renderArgs) })));
let ret = null;
let validityScore = 1;
try {

@@ -92,3 +90,3 @@ const resp = yield cachedChatCompletion(Object.assign({ model,

if (resp.choices.length > 0) {
ret = Object.assign({ name }, parseResponse(resp.choices[0].message, choiceScores));
return Object.assign({ name }, parseResponse(resp.choices[0].message, choiceScores));
}

@@ -100,4 +98,3 @@ else {

catch (error) {
validityScore = 0;
ret = {
return {
name,

@@ -108,3 +105,2 @@ score: 0,

}
return ret;
});

@@ -111,0 +107,0 @@ }

@@ -46,30 +46,9 @@ var __defProp = Object.defineProperty;

// js/util.ts
var NoopSpan = class {
constructor() {
this.kind = "span";
this.id = "";
this.span_id = "";
this.root_span_id = "";
}
log(_) {
}
startSpan(_0, _1) {
return this;
}
traced(_0, callback, _1) {
return callback(this);
}
end(args) {
var _a;
return (_a = args == null ? void 0 : args.endTime) != null ? _a : (/* @__PURE__ */ new Date()).getTime() / 1e3;
}
close(args) {
return this.end(args);
}
};
function currentSpan() {
function currentSpanTraced(name, callback, args) {
if (globalThis.__inherited_braintrust_state) {
return globalThis.__inherited_braintrust_state.currentSpan.getStore();
const currentSpan = globalThis.__inherited_braintrust_state.currentSpan.getStore();
return currentSpan.traced(name, (span) => callback(span.log), args);
} else {
return new NoopSpan();
return callback(() => {
});
}

@@ -82,36 +61,39 @@ }

const { cache, openAiApiKey, openAiOrganizationId, openAiBaseUrl } = options;
return await currentSpan().traced("OpenAI Completion", async (span) => {
var _b, _c, _d;
let cached = false;
let ret = await (cache == null ? void 0 : cache.get(params));
if (ret) {
cached = true;
} else {
const openai = new OpenAI({
apiKey: openAiApiKey || Env.OPENAI_API_KEY,
organization: openAiOrganizationId,
baseURL: openAiBaseUrl || PROXY_URL
return await currentSpanTraced(
"OpenAI Completion",
async (spanLog) => {
var _b, _c, _d;
let cached = false;
let ret = await (cache == null ? void 0 : cache.get(params));
if (ret) {
cached = true;
} else {
const openai = new OpenAI({
apiKey: openAiApiKey || Env.OPENAI_API_KEY,
organization: openAiOrganizationId,
baseURL: openAiBaseUrl || PROXY_URL
});
if (openai === null) {
throw new Error("OPENAI_API_KEY not set");
}
const completion = await openai.chat.completions.create(params);
await (cache == null ? void 0 : cache.set(params, completion));
ret = completion;
}
const _a = params, { messages } = _a, rest = __objRest(_a, ["messages"]);
spanLog({
input: messages,
metadata: __spreadProps(__spreadValues({}, rest), {
cached
}),
output: ret.choices[0],
metrics: {
tokens: (_b = ret.usage) == null ? void 0 : _b.total_tokens,
prompt_tokens: (_c = ret.usage) == null ? void 0 : _c.prompt_tokens,
completion_tokens: (_d = ret.usage) == null ? void 0 : _d.completion_tokens
}
});
if (openai === null) {
throw new Error("OPENAI_API_KEY not set");
}
const completion = await openai.chat.completions.create(params);
await (cache == null ? void 0 : cache.set(params, completion));
ret = completion;
return ret;
}
const _a = params, { messages } = _a, rest = __objRest(_a, ["messages"]);
span.log({
input: messages,
metadata: __spreadProps(__spreadValues({}, rest), {
cached
}),
output: ret.choices[0],
metrics: {
tokens: (_b = ret.usage) == null ? void 0 : _b.total_tokens,
prompt_tokens: (_c = ret.usage) == null ? void 0 : _c.prompt_tokens,
completion_tokens: (_d = ret.usage) == null ? void 0 : _d.completion_tokens
}
});
return ret;
});
);
}

@@ -309,4 +291,2 @@

}));
let ret = null;
let validityScore = 1;
try {

@@ -328,3 +308,3 @@ const resp = await cachedChatCompletion(

if (resp.choices.length > 0) {
ret = __spreadValues({
return __spreadValues({
name

@@ -336,4 +316,3 @@ }, parseResponse(resp.choices[0].message, choiceScores));

} catch (error) {
validityScore = 0;
ret = {
return {
name,

@@ -344,3 +323,2 @@ score: 0,

}
return ret;
}

@@ -347,0 +325,0 @@ function parseResponse(resp, choiceScores) {

@@ -23,3 +23,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { Env } from "./env.js";
import { currentSpan } from "./util.js";
import { currentSpanTraced } from "./util.js";
const PROXY_URL = "https://braintrustproxy.com/v1";

@@ -29,3 +29,3 @@ export function cachedChatCompletion(params, options) {

const { cache, openAiApiKey, openAiOrganizationId, openAiBaseUrl } = options;
return yield currentSpan().traced("OpenAI Completion", (span) => __awaiter(this, void 0, void 0, function* () {
return yield currentSpanTraced("OpenAI Completion", (spanLog) => __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c;

@@ -51,3 +51,3 @@ let cached = false;

const { messages } = params, rest = __rest(params, ["messages"]);
span.log({
spanLog({
input: messages,

@@ -54,0 +54,0 @@ metadata: Object.assign(Object.assign({}, rest), { cached }),

@@ -1,16 +0,5 @@

export declare class NoopSpan {
id: string;
span_id: string;
root_span_id: string;
kind: "span";
constructor();
log(_: any): void;
startSpan(_0: string, _1?: any): this;
traced<R>(_0: string, callback: (span: any) => R, _1: any): R;
end(args?: any): number;
close(args?: any): number;
}
export type SpanLogFn = (args: Record<string, any>) => void;
declare global {
var __inherited_braintrust_state: any;
}
export declare function currentSpan(): any;
export declare function currentSpanTraced<R>(name: string, callback: (spanLog: SpanLogFn) => R, args?: any): R;

@@ -1,31 +0,10 @@

/* This is copy/pasted from braintrust-sdk*/
export class NoopSpan {
constructor() {
this.kind = "span";
this.id = "";
this.span_id = "";
this.root_span_id = "";
}
log(_) { }
startSpan(_0, _1) {
return this;
}
traced(_0, callback, _1) {
return callback(this);
}
end(args) {
var _a;
return (_a = args === null || args === void 0 ? void 0 : args.endTime) !== null && _a !== void 0 ? _a : new Date().getTime() / 1000;
}
close(args) {
return this.end(args);
}
}
export function currentSpan() {
// Signature taken from sdk/js/src/logger.ts::Span::traced.
export function currentSpanTraced(name, callback, args) {
if (globalThis.__inherited_braintrust_state) {
return globalThis.__inherited_braintrust_state.currentSpan.getStore();
const currentSpan = globalThis.__inherited_braintrust_state.currentSpan.getStore();
return currentSpan.traced(name, (span) => callback(span.log), args);
}
else {
return new NoopSpan();
return callback(() => { });
}
}
{
"name": "autoevals",
"version": "0.0.32",
"version": "0.0.33",
"description": "Universal library for evaluating AI models",

@@ -5,0 +5,0 @@ "main": "jsdist/bundle.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc