magnitude-core
Version:
Magnitude e2e testing agent
99 lines (95 loc) • 5.15 kB
JavaScript
/*************************************************************************************************
Welcome to Baml! To use this generated code, please run one of the following:
$ npm install @boundaryml/baml
$ yarn add @boundaryml/baml
$ pnpm add @boundaryml/baml
*************************************************************************************************/
import { toBamlError } from "@boundaryml/baml";
export class AsyncHttpRequest {
runtime;
ctxManager;
constructor(runtime, ctxManager) {
this.runtime = runtime;
this.ctxManager = ctxManager;
}
async CreatePartialRecipe(memory, task, taskData, includeClaudeSpoof, __baml_options__) {
try {
const rawEnv = __baml_options__?.env ? { ...process.env, ...__baml_options__.env } : { ...process.env };
const env = Object.fromEntries(Object.entries(rawEnv).filter(([_, value]) => value !== undefined));
return await this.runtime.buildRequest("CreatePartialRecipe", {
"memory": memory, "task": task, "taskData": taskData, "includeClaudeSpoof": includeClaudeSpoof
}, this.ctxManager.cloneContext(), __baml_options__?.tb?.__tb(), __baml_options__?.clientRegistry, false, env);
}
catch (error) {
throw toBamlError(error);
}
}
async ExtractData(instructions, screenshot, domContent, includeClaudeSpoof, __baml_options__) {
try {
const rawEnv = __baml_options__?.env ? { ...process.env, ...__baml_options__.env } : { ...process.env };
const env = Object.fromEntries(Object.entries(rawEnv).filter(([_, value]) => value !== undefined));
return await this.runtime.buildRequest("ExtractData", {
"instructions": instructions, "screenshot": screenshot, "domContent": domContent, "includeClaudeSpoof": includeClaudeSpoof
}, this.ctxManager.cloneContext(), __baml_options__?.tb?.__tb(), __baml_options__?.clientRegistry, false, env);
}
catch (error) {
throw toBamlError(error);
}
}
async QueryMemory(memory, query, includeClaudeSpoof, __baml_options__) {
try {
const rawEnv = __baml_options__?.env ? { ...process.env, ...__baml_options__.env } : { ...process.env };
const env = Object.fromEntries(Object.entries(rawEnv).filter(([_, value]) => value !== undefined));
return await this.runtime.buildRequest("QueryMemory", {
"memory": memory, "query": query, "includeClaudeSpoof": includeClaudeSpoof
}, this.ctxManager.cloneContext(), __baml_options__?.tb?.__tb(), __baml_options__?.clientRegistry, false, env);
}
catch (error) {
throw toBamlError(error);
}
}
}
export class AsyncHttpStreamRequest {
runtime;
ctxManager;
constructor(runtime, ctxManager) {
this.runtime = runtime;
this.ctxManager = ctxManager;
}
async CreatePartialRecipe(memory, task, taskData, includeClaudeSpoof, __baml_options__) {
try {
const rawEnv = __baml_options__?.env ? { ...process.env, ...__baml_options__.env } : { ...process.env };
const env = Object.fromEntries(Object.entries(rawEnv).filter(([_, value]) => value !== undefined));
return await this.runtime.buildRequest("CreatePartialRecipe", {
"memory": memory, "task": task, "taskData": taskData, "includeClaudeSpoof": includeClaudeSpoof
}, this.ctxManager.cloneContext(), __baml_options__?.tb?.__tb(), __baml_options__?.clientRegistry, true, env);
}
catch (error) {
throw toBamlError(error);
}
}
async ExtractData(instructions, screenshot, domContent, includeClaudeSpoof, __baml_options__) {
try {
const rawEnv = __baml_options__?.env ? { ...process.env, ...__baml_options__.env } : { ...process.env };
const env = Object.fromEntries(Object.entries(rawEnv).filter(([_, value]) => value !== undefined));
return await this.runtime.buildRequest("ExtractData", {
"instructions": instructions, "screenshot": screenshot, "domContent": domContent, "includeClaudeSpoof": includeClaudeSpoof
}, this.ctxManager.cloneContext(), __baml_options__?.tb?.__tb(), __baml_options__?.clientRegistry, true, env);
}
catch (error) {
throw toBamlError(error);
}
}
async QueryMemory(memory, query, includeClaudeSpoof, __baml_options__) {
try {
const rawEnv = __baml_options__?.env ? { ...process.env, ...__baml_options__.env } : { ...process.env };
const env = Object.fromEntries(Object.entries(rawEnv).filter(([_, value]) => value !== undefined));
return await this.runtime.buildRequest("QueryMemory", {
"memory": memory, "query": query, "includeClaudeSpoof": includeClaudeSpoof
}, this.ctxManager.cloneContext(), __baml_options__?.tb?.__tb(), __baml_options__?.clientRegistry, true, env);
}
catch (error) {
throw toBamlError(error);
}
}
}