Skip to content
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

Merged
merged 4 commits into from
Jan 5, 2024
Merged

Conversation

mikeldking
Copy link
Contributor

resolves #25

Adds openAI embeddings instrumentaiton

@@ -2,4 +2,5 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
prettierPath: null,
Copy link
Contributor Author

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

Copy link
Contributor

@RogerHYang RogerHYang left a 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,
Copy link
Contributor

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...

Copy link
Contributor Author

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);
Copy link
Contributor

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.

Suggested change
span.recordException(error);
span.recordException(error);
span.setStatus({ code: SpanStatusCode.ERROR });
span.end();

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[JS][OpenAI] Instrumentation for Embedding calls
2 participants