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

chore(weave): capture request id for openai completions #3153

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

bcsherma
Copy link
Contributor

@bcsherma bcsherma commented Dec 5, 2024

Description

Openai integration captures the request id from completion responses and adds them to request_id on the call output.

@circle-job-mirror
Copy link

circle-job-mirror bot commented Dec 5, 2024

Copy link
Contributor Author

bcsherma commented Dec 5, 2024

@bcsherma bcsherma marked this pull request as ready for review December 6, 2024 00:30
@bcsherma bcsherma requested a review from a team as a code owner December 6, 2024 00:30
@@ -64,7 +64,7 @@ def test_instructor_openai(
assert op_name_from_ref(call.op_name) == "openai.chat.completions.create"
output = call.output
output_arguments = json.loads(
output.choices[0].message.tool_calls[0].function.arguments
output["choices"][0]["message"]["tool_calls"][0]["function"]["arguments"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you have to change from dot to bracket notation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output here comes from the post processor I'm modifying. In practice value can have many types depending on integrations, sdk versions, and I think even the type of completion being requested. In some cases the post processor returns a pydantic object, in some cases it returns a dict. For the standard case where we receive a ChatCompletion we will now return a dict with this extra key. The alternative would be adding the attribute to the pydantic class which feels hackier, and ultimately I think the output just gets dumped later in our pipe anyway.

@bcsherma bcsherma merged commit 8d01065 into master Dec 6, 2024
121 checks passed
@bcsherma bcsherma deleted the openai-request-id branch December 6, 2024 17:00
@github-actions github-actions bot locked and limited conversation to collaborators Dec 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants