https://www.boundaryml.com logo
TS Collectors examples not working
# help
b
https://docs.boundaryml.com/ref/baml_client/collector I can't reproduce the examples here, my collector always returns an empty
FunctionLog {}
, I tried both OpenAI and Groq clients :(( Also can't get
withOptions
to work, I have to parse the options into the function call directly to get the environment variables to set.
Copy code
ts
import type { RequestEvent, RequestHandler } from './$types';
import { b } from "$lib/baml_client"
import { Collector } from "@boundaryml/baml"
import type { Resume } from '$lib/baml_client/types'

export const GET: RequestHandler = async (event: RequestEvent) => {
    const collector = new Collector("my-collector")

    const env = {
        BAML_LOG: "WARN",
        OPENAI_API_KEY: "sk-...",
        GROQ_API_KEY: "gsk_...",
    }

    const res = await b.ExtractResume(
        "Aaron Sverdlen\n University of California, Berkeley\n B.S. Electrical Engineering and Computer Science",
        { collector, env }
    );
    
    console.log(collector.last?.id)
    console.log(collector.last?.usage)
    console.log(collector.logs)

    return new Response(JSON.stringify(res));
};
-->
Copy code
js
bfcall_01k7kkwt3pew486qw0a6rfjvpx
Usage {}
[ FunctionLog {} ]
v
thats odd! can you share what version you are on?
i will try and figure this out for you
b
I'm on version 0.211.2
j
Out of curiosity did you try with logging using spread or JSON.parse(JSON.stringify(collector.logs)) ?
v
fyi tagging @aaronv (BAML) here as he'd working on logging / collector stuff