feat: convert openai related tests to VCR#50
Merged
michaelneale merged 2 commits intosquare:mainfrom Sep 23, 2024
Merged
Conversation
This converts OpenAI tests (including Ollama) to VCR instead of manual patching. What this does is allow us to capture real responses and then be able to know the difference in format between the openai platform and others like Azure OpenAI or clones like ollama or localai. The first time a VCR test is run, it makes a call to the real service, and then afterwards it re-uses the data. Since the data remains, this also helps us safely refactor as otherwise only those with accounts will know if changes break. See https://pytest-vcr.readthedocs.io/en/latest/ Signed-off-by: Adrian Cole <adrian.cole@elastic.co>
Contributor
Author
|
cc @anuraaga if you want to drive by again ;) |
|
|
||
|
|
||
| @pytest.mark.vcr() | ||
| def test_openai_completion(monkeypatch): |
Contributor
Author
There was a problem hiding this comment.
so you can imagine we can add another test here for reasoning model, and then we can see the output, which would have reasoning tokens in it. like test_openai_completion_reasoning
anuraaga
reviewed
Sep 23, 2024
Contributor
|
LGTM |
| def test_openai_completion_integration(): | ||
| reply = openai_complete() | ||
|
|
||
| assert reply[0].content is not None |
Contributor
Author
There was a problem hiding this comment.
main thing here is that in the integration tests, we can't assert on exact values, where we can (and should) on the unit/vcr tests
michaelneale
approved these changes
Sep 23, 2024
Collaborator
michaelneale
left a comment
There was a problem hiding this comment.
I think this looks good
codefromthecrypt
pushed a commit
to codefromthecrypt/exchange
that referenced
this pull request
Oct 13, 2024
Co-authored-by: lily-de <119957291+lily-de@users.noreply.github.com>
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This converts OpenAI tests (including Ollama) to VCR instead of manual patching. What this does is allow us to capture real responses and then be able to know the difference in format between the openai platform and others like Azure OpenAI or clones like ollama or localai.
The first time a VCR test is run, it makes a call to the real service, and then afterwards it re-uses the data. Since the data remains, this also helps us safely refactor as otherwise only those with accounts will know if changes break.
See https://pytest-vcr.readthedocs.io/en/latest/