-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix (ai/core): Add null check for OTEL attributes #4783
base: main
Are you sure you want to change the base?
Conversation
0127fc0
to
53aec7e
Compare
53aec7e
to
be01951
Compare
Can you provide a reproduction code example for the bug that this fixes? |
It's not necessarily a bug because OTEL doesn't like undefined or null attributes but some the attributes we were passing to our tracing lib langsmith ended up being null and caused a crash. I figured since this was already handling undefined values adding null check wouldn't be too big of an issue. I can try and pull together a MRE. I thought a failing test would be enough to cover it. |
What are the major concerns with adding a more defensive check here? Is it the new null type on the argument that no longer enforces values to not be null by TS that you are concerned about? |
We need to support OTEL not LangSmith. Passing |
Alright here is the MRE without a dependency on langsmith import { generateText } from 'ai';
import { ollama } from 'ollama-ai-provider';
const model = ollama('llama3.2');
const prompt = 'Tell a joke';
const result = await generateText({
model,
prompt,
experimental_telemetry: {
isEnabled: true,
metadata: {
// @ts-expect-error
nullValue: null,
prompt,
}
},
});
console.log(result.text); Error:
|
I'm getting the following (expected) typescript error:
https://github.com/open-telemetry/opentelemetry-js/blob/main/api/src/common/Attributes.ts#L35 I'm trying to understand the request here. Do you want us to support |
My mind was boggle today when i learned that in JS
(typeof null === 'object') === true
So this helps protect from trying to access'input' in null
which throws below