-
Notifications
You must be signed in to change notification settings - Fork 44
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
feat(js): OpenAI embeddings Instrumentation #34
Conversation
@@ -2,4 +2,5 @@ | |||
module.exports = { | |||
preset: "ts-jest", | |||
testEnvironment: "node", | |||
prettierPath: null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jest doesn't support prettier 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
attributes: { | ||
[SemanticConventions.OPENINFERENCE_SPAN_KIND]: | ||
OpenInferenceSpanKind.EMBEDDING, | ||
[SemanticConventions.EMBEDDING_MODEL_NAME]: body.model, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want to capture model
from the response instead, because the one in the request can be part of invocation_parameters
. Also, for Azure this is the deployment name, although last I checked, Azure is actually returning the wrong model names in embeddings response...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to double-check as a follow-up on Azure. It's a bit different in JS. They have a supplamentary package. I'll file a follow-up ticket for that.
(error) => { | ||
// Push the error to the span | ||
if (error) { | ||
span.recordException(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recording exceptions doesn't actually update the status, because a span can record multiple exceptions such as retry errors and still turn out OK
.
span.recordException(error); | |
span.recordException(error); | |
span.setStatus({ code: SpanStatusCode.ERROR }); | |
span.end(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I was thinking of leaving it mimimal - I'll at least set the status code. Might leave off the span end for now. Not sure if that's necessary. Will look into it a bit more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh actually I can put it below. I'll do that.
resolves #25
Adds openAI embeddings instrumentaiton