magnitude-core
Version:
Magnitude e2e testing agent
87 lines (83 loc) • 4.2 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 LlmResponseParser {
runtime;
ctxManager;
constructor(runtime, ctxManager) {
this.runtime = runtime;
this.ctxManager = ctxManager;
}
CreatePartialRecipe(llmResponse, __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 this.runtime.parseLlmResponse("CreatePartialRecipe", llmResponse, false, this.ctxManager.cloneContext(), __baml_options__?.tb?.__tb(), __baml_options__?.clientRegistry, env);
}
catch (error) {
throw toBamlError(error);
}
}
ExtractData(llmResponse, __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 this.runtime.parseLlmResponse("ExtractData", llmResponse, false, this.ctxManager.cloneContext(), __baml_options__?.tb?.__tb(), __baml_options__?.clientRegistry, env);
}
catch (error) {
throw toBamlError(error);
}
}
QueryMemory(llmResponse, __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 this.runtime.parseLlmResponse("QueryMemory", llmResponse, false, this.ctxManager.cloneContext(), __baml_options__?.tb?.__tb(), __baml_options__?.clientRegistry, env);
}
catch (error) {
throw toBamlError(error);
}
}
}
export class LlmStreamParser {
runtime;
ctxManager;
constructor(runtime, ctxManager) {
this.runtime = runtime;
this.ctxManager = ctxManager;
}
CreatePartialRecipe(llmResponse, __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 this.runtime.parseLlmResponse("CreatePartialRecipe", llmResponse, true, this.ctxManager.cloneContext(), __baml_options__?.tb?.__tb(), __baml_options__?.clientRegistry, env);
}
catch (error) {
throw toBamlError(error);
}
}
ExtractData(llmResponse, __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 this.runtime.parseLlmResponse("ExtractData", llmResponse, true, this.ctxManager.cloneContext(), __baml_options__?.tb?.__tb(), __baml_options__?.clientRegistry, env);
}
catch (error) {
throw toBamlError(error);
}
}
QueryMemory(llmResponse, __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 this.runtime.parseLlmResponse("QueryMemory", llmResponse, true, this.ctxManager.cloneContext(), __baml_options__?.tb?.__tb(), __baml_options__?.clientRegistry, env);
}
catch (error) {
throw toBamlError(error);
}
}
}