Socket
Socket
Sign inDemoInstall

lunary

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lunary - npm Package Compare versions

Comparing version 0.7.5 to 0.7.6

dist/chunk-4WMCGW76.cjs

4

dist/browser.js
import {
browser_default
} from "./chunk-HNO53DQ5.js";
import "./chunk-2DRTHKIK.js";
} from "./chunk-JQUP2JBN.js";
import "./chunk-OR46OCV2.js";
import "./chunk-AGSXOS4O.js";

@@ -6,0 +6,0 @@ export {

import {
src_default
} from "./chunk-JULUA5HT.js";
import "./chunk-2DRTHKIK.js";
} from "./chunk-ZYD5QO2H.js";
import "./chunk-OR46OCV2.js";
import "./chunk-AGSXOS4O.js";

@@ -6,0 +6,0 @@ export {

import {
src_default
} from "./chunk-JULUA5HT.js";
import "./chunk-2DRTHKIK.js";
} from "./chunk-ZYD5QO2H.js";
import "./chunk-OR46OCV2.js";
import {
ChatPromptTemplate
} from "./chunk-ZUW6MUUB.js";
} from "./chunk-POGBUKPE.js";
import {

@@ -12,3 +12,3 @@ BaseCallbackHandler,

getEnvironmentVariable
} from "./chunk-CG7GNE34.js";
} from "./chunk-6KX3NNHJ.js";
import {

@@ -94,3 +94,3 @@ __name

var parseExtraAndName = /* @__PURE__ */ __name((llm, extraParams, metadata) => {
const params = {
const allParams = {
...extraParams?.invocation_params ?? {},

@@ -101,10 +101,21 @@ // @ts-ignore this is a valid property

};
const { model, model_name, modelName, model_id, userId, userProps, ...rest } = params;
const { model, model_name, modelName, model_id, userId, userProps, ...rest } = allParams;
const name = model || modelName || model_name || model_id || llm.id.at(-1);
const extra = Object.fromEntries(
Object.entries(rest).filter(
([key]) => PARAMS_TO_CAPTURE.includes(key) || ["string", "number", "boolean"].includes(typeof rest[key])
const params = Object.fromEntries(
Object.entries(rest).filter(([key]) => PARAMS_TO_CAPTURE.includes(key))
);
const cleanedMetadata = Object.fromEntries(
Object.entries(metadata).filter(
([key]) => !PARAMS_TO_CAPTURE.includes(key) && ![
"model",
"model_name",
"modelName",
"model_id",
"userId",
"userProps",
"tags"
].includes(key) && ["string", "number", "boolean"].includes(typeof metadata[key])
)
);
return { name, extra, userId, userProps };
return { name, params, cleanedMetadata, userId, userProps };
}, "parseExtraAndName");

@@ -124,3 +135,3 @@ var LunaryHandler = class extends BaseCallbackHandler {

verbose,
appId: appId ?? getEnvironmentVariable("LUNARY_APP_ID") ?? getEnvironmentVariable("LLMONITOR_APP_ID"),
appId: appId ?? getEnvironmentVariable("LUNARY_PUBLIC_KEY") ?? getEnvironmentVariable("LUNARY_APP_ID") ?? getEnvironmentVariable("LLMONITOR_APP_ID"),
apiUrl: apiUrl ?? getEnvironmentVariable("LUNARY_API_URL") ?? getEnvironmentVariable("LLMONITOR_API_URL")

@@ -131,7 +142,3 @@ });

async handleLLMStart(llm, prompts, runId, parentRunId, extraParams, tags, metadata) {
const { name, extra, userId, userProps } = parseExtraAndName(
llm,
extraParams,
metadata
);
const { name, params, cleanedMetadata, userId, userProps } = parseExtraAndName(llm, extraParams, metadata);
await this.lunary.trackEvent("llm", "start", {

@@ -142,3 +149,4 @@ runId,

input: convertToLunaryMessages(prompts),
extra,
params,
metadata: cleanedMetadata,
userId,

@@ -151,7 +159,3 @@ userProps,

async handleChatModelStart(llm, messages, runId, parentRunId, extraParams, tags, metadata) {
const { name, extra, userId, userProps } = parseExtraAndName(
llm,
extraParams,
metadata
);
const { name, params, cleanedMetadata, userId, userProps } = parseExtraAndName(llm, extraParams, metadata);
await this.lunary.trackEvent("llm", "start", {

@@ -162,3 +166,4 @@ runId,

input: convertToLunaryMessages(messages),
extra,
params,
metadata: cleanedMetadata,
userId,

@@ -188,4 +193,4 @@ userProps,

async handleChainStart(chain, inputs, runId, parentRunId, tags, metadata) {
const { agentName, userId, userProps, ...rest } = metadata || {};
const name = agentName || chain.id.at(-1);
const { agentName, name, userId, userProps, ...rest } = metadata || {};
const actualName = name || agentName || chain.id.at(-1);
const runType = agentName || ["AgentExecutor", "PlanAndExecute"].includes(name) ? "agent" : "chain";

@@ -195,7 +200,7 @@ await this.lunary.trackEvent(runType, "start", {

parentRunId,
name,
name: actualName,
userId,
userProps,
input: parseInput(inputs),
extra: rest,
metadata: rest,
tags,

@@ -227,3 +232,3 @@ runtime: "langchain-js"

input: query,
extra: rest,
metadata: rest,
tags,

@@ -254,3 +259,3 @@ runtime: "langchain-js"

input,
extra: rest,
metadata: rest,
tags,

@@ -257,0 +262,0 @@ runtime: "langchain-js"

@@ -1,2 +0,2 @@

import { WrapExtras, WrappedFn, Template, WrappedReturn, cJSON } from './types.js';
import { WrapExtras, Template, WrappedReturn, cJSON } from './types.js';
import OpenAI from 'openai';

@@ -6,5 +6,2 @@ import { APIPromise } from 'openai/core';

type WrappedOldOpenAi<T> = Omit<T, "createChatCompletion"> & {
createChatCompletion: WrappedFn<T["createChatCompletion"]>;
};
type CreateFunction<T, U> = (body: T, options?: OpenAI.RequestOptions) => U;

@@ -14,2 +11,3 @@ type NewParams = {

userProps?: cJSON;
metadata?: cJSON;
};

@@ -20,3 +18,3 @@ type WrapCreateFunction<T, U> = (body: (T & NewParams) | Template, options?: OpenAI.RequestOptions) => WrappedReturn<CreateFunction<T, U>>;

completions: {
create: WrapCreateFunction<OpenAI.Chat.ChatCompletionCreateParams, APIPromise<OpenAI.Chat.ChatCompletion>> & WrapCreateFunction<OpenAI.Chat.ChatCompletionCreateParamsStreaming, APIPromise<OpenAIStreaming.Stream<OpenAI.Chat.ChatCompletionChunk>>> & WrapCreateFunction<OpenAI.Chat.ChatCompletionCreateParams, APIPromise<OpenAIStreaming.Stream<OpenAI.Chat.ChatCompletionChunk>> | APIPromise<OpenAI.Chat.ChatCompletion>>;
create: WrapCreateFunction<OpenAI.Chat.ChatCompletionCreateParamsNonStreaming, APIPromise<OpenAI.ChatCompletion>> & WrapCreateFunction<OpenAI.Chat.ChatCompletionCreateParamsStreaming, APIPromise<OpenAIStreaming.Stream<OpenAI.ChatCompletionChunk>>> & WrapCreateFunction<OpenAI.Chat.ChatCompletionCreateParams, APIPromise<OpenAI.ChatCompletion> | APIPromise<OpenAIStreaming.Stream<OpenAI.ChatCompletionChunk>>>;
};

@@ -26,5 +24,4 @@ };

type WrappedOpenAi<T> = Omit<T, "chat"> & WrapCreate<T>;
declare function openAIv3<T extends any>(openai: T, params?: WrapExtras): WrappedOldOpenAi<T>;
declare function monitorOpenAI<T extends any>(openai: T, params?: WrapExtras): WrappedOpenAi<T>;
export { monitorOpenAI, openAIv3 };
export { monitorOpenAI };
import {
src_default
} from "./chunk-JULUA5HT.js";
} from "./chunk-ZYD5QO2H.js";
import {
cleanExtra
} from "./chunk-2DRTHKIK.js";
} from "./chunk-OR46OCV2.js";
import {

@@ -73,29 +73,2 @@ __name

];
function openAIv3(openai, params = {}) {
const createChatCompletion = openai.createChatCompletion.bind(openai);
const wrapped = src_default.wrapModel(createChatCompletion, {
nameParser: (request) => request.model,
inputParser: (request) => request.messages.map(parseOpenaiMessage),
extraParser: (request) => {
const rawExtra = {
temperature: request.temperature,
maxTokens: request.max_tokens,
frequencyPenalty: request.frequency_penalty,
presencePenalty: request.presence_penalty,
stop: request.stop,
functionCall: request.function_call
};
return cleanExtra(rawExtra);
},
outputParser: ({ data }) => parseOpenaiMessage(data.choices[0]),
tokensUsageParser: async ({ data }) => ({
completion: data.usage?.completion_tokens,
prompt: data.usage?.prompt_tokens
}),
...params
});
openai.createChatCompletion = wrapped;
return openai;
}
__name(openAIv3, "openAIv3");
function monitorOpenAI(openai, params = {}) {

@@ -166,3 +139,3 @@ const createChatCompletion = openai.chat.completions.create;

inputParser: (request) => request.messages.map(parseOpenaiMessage),
extraParser: (request) => {
paramsParser: (request) => {
const rawExtra = {};

@@ -175,2 +148,7 @@ for (const param of PARAMS_TO_CAPTURE) {

},
metadataParser(request) {
const metadata = request.metadata;
delete request.metadata;
return metadata;
},
outputParser: (res) => parseOpenaiMessage(res.choices[0].message || ""),

@@ -213,4 +191,3 @@ tokensUsageParser: async (res) => {

export {
monitorOpenAI,
openAIv3
monitorOpenAI
};

@@ -11,3 +11,3 @@ import { cJSON } from './types.js';

id?: string;
role: "user" | "assistant" | "tool" | "system";
role: "user" | "assistant" | "system" | "tool";
content?: string;

@@ -14,0 +14,0 @@ isRetry?: boolean;

import {
browser_default
} from "./chunk-HNO53DQ5.js";
import "./chunk-2DRTHKIK.js";
} from "./chunk-JQUP2JBN.js";
import "./chunk-OR46OCV2.js";
import {

@@ -6,0 +6,0 @@ __name

@@ -19,2 +19,4 @@ type cJSON = string | number | boolean | null | undefined | {

parentRunId?: string;
params?: cJSON;
metadata?: cJSON;
extra?: cJSON;

@@ -50,2 +52,4 @@ tags?: string[];

name?: string;
metadata?: cJSON;
params?: cJSON;
extra?: cJSON;

@@ -59,3 +63,4 @@ tags?: string[];

inputParser?: (...args: Parameters<T>) => cJSON;
extraParser?: (...args: Parameters<T>) => cJSON;
metadataParser?: (...args: Parameters<T>) => cJSON;
paramsParser?: (...args: Parameters<T>) => cJSON;
nameParser?: (...args: Parameters<T>) => string;

@@ -83,2 +88,3 @@ outputParser?: (result: Awaited<ReturnType<T>>) => cJSON;

prompt?: string;
stream?: boolean;
messages?: ChatMessage[];

@@ -91,2 +97,4 @@ model?: string;

frequency_penalty?: number;
tools?: any[];
seed?: number;
stop?: string[];

@@ -93,0 +101,0 @@ function?: any;

{
"name": "lunary",
"version": "0.7.5",
"version": "0.7.6",
"description": "Lunary is an open-source platform for AI developers.",

@@ -67,15 +67,15 @@ "type": "module",

"devDependencies": {
"@langchain/community": "^0.0.34",
"@langchain/openai": "^0.0.15",
"@types/node": "^20.11.24",
"@types/react": "^18.2.61",
"bun-types": "^1.0.29",
"@langchain/community": "^0.0.43",
"@langchain/openai": "^0.0.23",
"@types/node": "^20.11.30",
"@types/react": "^18.2.70",
"bun-types": "^1.0.35",
"dotenv": "^16.4.5",
"hnswlib-node": "^1.4.2",
"langchain": "^0.1.25",
"openai": "^4.24.1",
"langchain": "^0.1.30",
"llamaindex": "^0.1.21",
"openai": "^4.29.2",
"react": "^18.2.0",
"stream-buffers": "^3.0.2",
"tsup": "^7.3.0",
"typescript": "^5.3.3"
"typescript": "^5.4.3"
},

@@ -82,0 +82,0 @@ "prettier": {

@@ -18,3 +18,3 @@ <div align="center">

It is compatible with Langchain JS, AutoGPT and all the other libraries.
It is compatible with Langchain JS, AutoGPT and other libraries.

@@ -21,0 +21,0 @@ To get started, get a project ID by registering [here](https://lunary.ai).

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc