@dvina/agents 0.3.7 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-NHWEEBN2.mjs +159 -0
- package/dist/chunk-NHWEEBN2.mjs.map +1 -0
- package/dist/eval/index.d.mts +117 -0
- package/dist/eval/index.d.ts +117 -0
- package/dist/eval/index.js +643 -0
- package/dist/eval/index.js.map +1 -0
- package/dist/eval/index.mjs +483 -0
- package/dist/eval/index.mjs.map +1 -0
- package/dist/index.d.mts +4 -138
- package/dist/index.d.ts +4 -138
- package/dist/index.js +74 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -125
- package/dist/index.mjs.map +1 -1
- package/dist/model-resolver-U0J9x1a6.d.mts +158 -0
- package/dist/model-resolver-U0J9x1a6.d.ts +158 -0
- package/package.json +33 -4
package/dist/index.mjs
CHANGED
|
@@ -1,34 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
-
}) : x)(function(x) {
|
|
10
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
-
});
|
|
13
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
-
};
|
|
16
|
-
var __copyProps = (to, from, except, desc) => {
|
|
17
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
-
for (let key of __getOwnPropNames(from))
|
|
19
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
-
mod
|
|
31
|
-
));
|
|
1
|
+
import {
|
|
2
|
+
LangchainModelResolver,
|
|
3
|
+
__commonJS,
|
|
4
|
+
__require,
|
|
5
|
+
__toESM,
|
|
6
|
+
convertToLangchainMessages
|
|
7
|
+
} from "./chunk-NHWEEBN2.mjs";
|
|
32
8
|
|
|
33
9
|
// node_modules/braces/lib/utils.js
|
|
34
10
|
var require_utils = __commonJS({
|
|
@@ -21098,8 +21074,7 @@ import { ToolMessage as ToolMessage2 } from "@langchain/core/messages";
|
|
|
21098
21074
|
import { Command as Command2 } from "@langchain/langgraph";
|
|
21099
21075
|
import {
|
|
21100
21076
|
AIMessageChunk,
|
|
21101
|
-
createMiddleware as createMiddleware2
|
|
21102
|
-
HumanMessage as HumanMessage2
|
|
21077
|
+
createMiddleware as createMiddleware2
|
|
21103
21078
|
} from "langchain";
|
|
21104
21079
|
var ENABLE_STREAM_DEBUG_LOGS = false;
|
|
21105
21080
|
function debugLogStream(type, text) {
|
|
@@ -21163,21 +21138,10 @@ var LangchainAgent = class {
|
|
|
21163
21138
|
messageCountBefore = stateBefore?.values?.messages?.length || 0;
|
|
21164
21139
|
} catch {
|
|
21165
21140
|
}
|
|
21141
|
+
const messages = convertToLangchainMessages(input.messages);
|
|
21166
21142
|
const result = await this.deepAgent.invoke(
|
|
21167
21143
|
{
|
|
21168
|
-
messages
|
|
21169
|
-
(m) => new HumanMessage2({
|
|
21170
|
-
content: m.content.map((c) => {
|
|
21171
|
-
if (c.type === "image") {
|
|
21172
|
-
return {
|
|
21173
|
-
type: "image_url",
|
|
21174
|
-
image_url: { url: c.url }
|
|
21175
|
-
};
|
|
21176
|
-
}
|
|
21177
|
-
return c;
|
|
21178
|
-
})
|
|
21179
|
-
})
|
|
21180
|
-
)
|
|
21144
|
+
messages
|
|
21181
21145
|
},
|
|
21182
21146
|
{
|
|
21183
21147
|
configurable: {
|
|
@@ -21249,19 +21213,7 @@ var LangchainAgent = class {
|
|
|
21249
21213
|
totalTokens: 0,
|
|
21250
21214
|
cachedPromptTokens: 0
|
|
21251
21215
|
};
|
|
21252
|
-
const messages = input.messages
|
|
21253
|
-
(m) => new HumanMessage2({
|
|
21254
|
-
content: m.content.map((c) => {
|
|
21255
|
-
if (c.type === "image") {
|
|
21256
|
-
return {
|
|
21257
|
-
type: "image_url",
|
|
21258
|
-
image_url: { url: c.url }
|
|
21259
|
-
};
|
|
21260
|
-
}
|
|
21261
|
-
return c;
|
|
21262
|
-
})
|
|
21263
|
-
})
|
|
21264
|
-
);
|
|
21216
|
+
const messages = convertToLangchainMessages(input.messages);
|
|
21265
21217
|
debugLogStream("message_start", "");
|
|
21266
21218
|
yield { type: "message_start" };
|
|
21267
21219
|
const stream = await this.deepAgent.stream(
|
|
@@ -21450,72 +21402,6 @@ var LangchainAgent = class {
|
|
|
21450
21402
|
}
|
|
21451
21403
|
};
|
|
21452
21404
|
|
|
21453
|
-
// src/runtime/langchain/model-resolver.ts
|
|
21454
|
-
import { AzureChatOpenAI, ChatOpenAI } from "@langchain/openai";
|
|
21455
|
-
var LangchainModelResolver = class {
|
|
21456
|
-
constructor(config) {
|
|
21457
|
-
this.config = config;
|
|
21458
|
-
}
|
|
21459
|
-
resolve(modelString, tags) {
|
|
21460
|
-
const parts = modelString.split(":");
|
|
21461
|
-
if (parts.length === 2) {
|
|
21462
|
-
const [provider, modelName] = parts;
|
|
21463
|
-
return this.resolveByProvider(provider, "default", modelName, tags);
|
|
21464
|
-
}
|
|
21465
|
-
if (parts.length === 3) {
|
|
21466
|
-
const [provider, configName, modelName] = parts;
|
|
21467
|
-
return this.resolveByProvider(provider, configName, modelName, tags);
|
|
21468
|
-
}
|
|
21469
|
-
throw new Error(
|
|
21470
|
-
'Model string must follow format "provider:modelName" (uses "default" config) or "provider:configName:modelName"'
|
|
21471
|
-
);
|
|
21472
|
-
}
|
|
21473
|
-
resolveByProvider(provider, configName, modelName, tags) {
|
|
21474
|
-
switch (provider) {
|
|
21475
|
-
case "openai":
|
|
21476
|
-
return this.resolveOpenAI(configName, modelName, tags);
|
|
21477
|
-
case "azure":
|
|
21478
|
-
return this.resolveAzure(configName, modelName, tags);
|
|
21479
|
-
default:
|
|
21480
|
-
throw new Error(`Unsupported model provider: ${provider}`);
|
|
21481
|
-
}
|
|
21482
|
-
}
|
|
21483
|
-
resolveOpenAI(configName, modelName, tags) {
|
|
21484
|
-
const providerConfig = this.config.openai?.[configName];
|
|
21485
|
-
if (!providerConfig) {
|
|
21486
|
-
throw new Error(`Configuration "${configName}" for provider "openai" is missing`);
|
|
21487
|
-
}
|
|
21488
|
-
return new ChatOpenAI({
|
|
21489
|
-
apiKey: providerConfig.apiKey,
|
|
21490
|
-
modelName,
|
|
21491
|
-
tags
|
|
21492
|
-
});
|
|
21493
|
-
}
|
|
21494
|
-
resolveAzure(configName, deploymentName, tags) {
|
|
21495
|
-
const providerConfig = this.config.azure?.[configName];
|
|
21496
|
-
if (!providerConfig) {
|
|
21497
|
-
throw new Error(`Configuration "${configName}" for provider "azure" is missing`);
|
|
21498
|
-
}
|
|
21499
|
-
return new AzureChatOpenAI({
|
|
21500
|
-
model: providerConfig.model,
|
|
21501
|
-
// shows (perhaps even uses) 3.5-turbo when not specifid
|
|
21502
|
-
azureOpenAIApiKey: providerConfig.apiKey,
|
|
21503
|
-
azureOpenAIApiInstanceName: this.extractInstanceName(providerConfig.endpoint),
|
|
21504
|
-
azureOpenAIApiDeploymentName: deploymentName,
|
|
21505
|
-
azureOpenAIApiVersion: providerConfig.apiVersion,
|
|
21506
|
-
tags
|
|
21507
|
-
});
|
|
21508
|
-
}
|
|
21509
|
-
extractInstanceName(endpoint) {
|
|
21510
|
-
try {
|
|
21511
|
-
const url = new URL(endpoint);
|
|
21512
|
-
return url.hostname.split(".")[0];
|
|
21513
|
-
} catch (e) {
|
|
21514
|
-
return endpoint;
|
|
21515
|
-
}
|
|
21516
|
-
}
|
|
21517
|
-
};
|
|
21518
|
-
|
|
21519
21405
|
// src/runtime/langchain/factory.ts
|
|
21520
21406
|
var LangchainAgentFactory = class {
|
|
21521
21407
|
constructor(modelConfig, saverConfig, storeConfig) {
|