@orq-ai/evaluatorq 1.2.0-rc.4 → 1.2.1
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/README.md +140 -8
- package/dist/lib/integrations/ai-sdk/convert.d.ts +3 -3
- package/dist/lib/integrations/ai-sdk/convert.d.ts.map +1 -1
- package/dist/lib/integrations/ai-sdk/convert.js +44 -4
- package/dist/lib/integrations/ai-sdk/types.d.ts +6 -0
- package/dist/lib/integrations/ai-sdk/types.d.ts.map +1 -1
- package/dist/lib/integrations/ai-sdk/wrap-agent.d.ts.map +1 -1
- package/dist/lib/integrations/ai-sdk/wrap-agent.js +71 -5
- package/dist/lib/integrations/common/utils.d.ts +9 -0
- package/dist/lib/integrations/common/utils.d.ts.map +1 -1
- package/dist/lib/integrations/common/utils.js +10 -0
- package/dist/lib/integrations/langchain/convert.d.ts.map +1 -1
- package/dist/lib/integrations/langchain/convert.js +10 -6
- package/dist/lib/integrations/langchain/types.d.ts +6 -0
- package/dist/lib/integrations/langchain/types.d.ts.map +1 -1
- package/dist/lib/integrations/langchain/wrap-agent.d.ts.map +1 -1
- package/dist/lib/integrations/langchain/wrap-agent.js +56 -7
- package/dist/lib/integrations/openresponses/index.d.ts +12 -0
- package/dist/lib/integrations/openresponses/index.d.ts.map +1 -1
- package/dist/lib/integrations/openresponses/index.js +19 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Wrapper functions for LangChain/LangGraph agents to integrate with evaluatorq.
|
|
3
3
|
*/
|
|
4
4
|
import { toJsonSchema } from "@langchain/core/utils/json_schema";
|
|
5
|
-
import { extractPromptFromData } from "../common/
|
|
5
|
+
import { extractMessagesFromData, extractPromptFromData, } from "../common/utils.js";
|
|
6
6
|
import { convertToOpenResponses } from "./convert.js";
|
|
7
7
|
/**
|
|
8
8
|
* Extract JSON schema parameters from a schema object.
|
|
@@ -85,13 +85,62 @@ function convertToolToDefinition(tool) {
|
|
|
85
85
|
* @returns An evaluatorq Job function
|
|
86
86
|
*/
|
|
87
87
|
export function wrapLangChainAgent(agent, options = {}) {
|
|
88
|
-
const { name = "agent", promptKey = "prompt", tools } = options;
|
|
88
|
+
const { name = "agent", promptKey = "prompt", instructions, tools } = options;
|
|
89
89
|
return async (data, _row) => {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
const inputMessages = extractMessagesFromData(data);
|
|
91
|
+
const hasMessages = inputMessages !== undefined;
|
|
92
|
+
const hasPrompt = typeof data.inputs[promptKey] === "string" && data.inputs[promptKey];
|
|
93
|
+
let result;
|
|
94
|
+
if (instructions) {
|
|
95
|
+
// Resolve instructions (static string or dynamic function)
|
|
96
|
+
const resolvedInstructions = typeof instructions === "function" ? instructions(data) : instructions;
|
|
97
|
+
const systemMessage = { role: "system", content: resolvedInstructions };
|
|
98
|
+
let messages;
|
|
99
|
+
if (hasMessages && hasPrompt) {
|
|
100
|
+
messages = [
|
|
101
|
+
systemMessage,
|
|
102
|
+
...inputMessages,
|
|
103
|
+
{ role: "user", content: data.inputs[promptKey] },
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
else if (hasPrompt) {
|
|
107
|
+
messages = [
|
|
108
|
+
systemMessage,
|
|
109
|
+
{ role: "user", content: data.inputs[promptKey] },
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
else if (hasMessages) {
|
|
113
|
+
messages = [systemMessage, ...inputMessages];
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
throw new Error("Expected data.inputs.messages (array) or data.inputs.prompt (string), but neither was provided");
|
|
117
|
+
}
|
|
118
|
+
result = await agent.invoke({ messages });
|
|
119
|
+
}
|
|
120
|
+
else if (hasMessages && hasPrompt) {
|
|
121
|
+
// Both exist — merge messages + prompt appended as user message
|
|
122
|
+
const messages = [
|
|
123
|
+
...inputMessages,
|
|
124
|
+
{ role: "user", content: data.inputs[promptKey] },
|
|
125
|
+
];
|
|
126
|
+
result = await agent.invoke({ messages });
|
|
127
|
+
}
|
|
128
|
+
else if (hasPrompt) {
|
|
129
|
+
// Prompt only — wrap as single user message
|
|
130
|
+
const prompt = extractPromptFromData(data, promptKey);
|
|
131
|
+
result = await agent.invoke({
|
|
132
|
+
messages: [{ role: "user", content: prompt }],
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
else if (hasMessages) {
|
|
136
|
+
// Messages only — pass directly
|
|
137
|
+
result = await agent.invoke({
|
|
138
|
+
messages: inputMessages,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
throw new Error("Expected data.inputs.messages (array) or data.inputs.prompt (string), but neither was provided");
|
|
143
|
+
}
|
|
95
144
|
// Extract messages from result
|
|
96
145
|
const messages = result.messages ?? [];
|
|
97
146
|
// Get tools from agent if not provided explicitly
|
|
@@ -188,6 +188,8 @@ export interface ResponseResource {
|
|
|
188
188
|
previous_response_id: string | null;
|
|
189
189
|
/** System instructions provided to the model. */
|
|
190
190
|
instructions: string | null;
|
|
191
|
+
/** The input items that were sent to the model. */
|
|
192
|
+
input: ItemField[];
|
|
191
193
|
/** The output items that were generated by the model. */
|
|
192
194
|
output: ItemField[];
|
|
193
195
|
/** Error information if the response failed. */
|
|
@@ -233,4 +235,14 @@ export interface ResponseResource {
|
|
|
233
235
|
/** Prompt cache key if caching was used. */
|
|
234
236
|
prompt_cache_key: string | null;
|
|
235
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Extracts the text content from an Output value that is a ResponseResource.
|
|
240
|
+
*
|
|
241
|
+
* Finds the first assistant message with `output_text` content and returns its text.
|
|
242
|
+
* Returns an empty string if the output is not a ResponseResource or contains no text.
|
|
243
|
+
*
|
|
244
|
+
* @param output - The output from a job (can be any Output type)
|
|
245
|
+
* @returns The extracted text string, or empty string if not found
|
|
246
|
+
*/
|
|
247
|
+
export declare function extractText(output: unknown): string;
|
|
236
248
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/integrations/openresponses/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,eAAO,MAAM,eAAe;;;;;CAKlB,CAAC;AAEX,MAAM,MAAM,WAAW,GACrB,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAEzD,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAC;AAEX,MAAM,MAAM,aAAa,GACvB,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE7D,eAAO,MAAM,sBAAsB;;;;CAIzB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,OAAO,sBAAsB,CAAC,CAAC;AAEvE,eAAO,MAAM,4BAA4B;;;;CAI/B,CAAC;AAEX,MAAM,MAAM,4BAA4B,GACtC,CAAC,OAAO,4BAA4B,CAAC,CAAC,MAAM,OAAO,4BAA4B,CAAC,CAAC;AAMnF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,IAAI,EAAE,YAAY,CAAC;IACnB,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,IAAI,EAAE,aAAa,CAAC;IACpB,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,WAAW,EAAE,OAAO,EAAE,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAMD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8DAA8D;IAC9D,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,qEAAq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omplete: "incomplete",
|
|
31
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Extracts the text content from an Output value that is a ResponseResource.
|
|
34
|
+
*
|
|
35
|
+
* Finds the first assistant message with `output_text` content and returns its text.
|
|
36
|
+
* Returns an empty string if the output is not a ResponseResource or contains no text.
|
|
37
|
+
*
|
|
38
|
+
* @param output - The output from a job (can be any Output type)
|
|
39
|
+
* @returns The extracted text string, or empty string if not found
|
|
40
|
+
*/
|
|
41
|
+
export function extractText(output) {
|
|
42
|
+
const res = output;
|
|
43
|
+
if (!res?.output)
|
|
44
|
+
return "";
|
|
45
|
+
const message = res.output.find((item) => item.type === "message");
|
|
46
|
+
if (!message)
|
|
47
|
+
return "";
|
|
48
|
+
const textContent = message.content.find((c) => c.type === "output_text");
|
|
49
|
+
return textContent?.text ?? "";
|
|
50
|
+
}
|