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

Add OpenAI tests #4846

Merged
merged 10 commits into from
Aug 5, 2024
Merged

Add OpenAI tests #4846

merged 10 commits into from
Aug 5, 2024

Conversation

dureuill
Copy link
Contributor

Pull Request

Related issue

Part of fixing #4757

What does this PR do?

  • OpenAI embedder: don't pass apiKey when it is empty (slightly improves error messages)
  • rest embedder and rest-based embedders: specialize the authorization denied error message depending on the configuration source
  • fix existing tests
  • Adds assets containing prerecorded texts to embed and the embeddings obtained from OpenAI
  • Adds an asset containing a tokenized long document and the embedding obtained from OpenAI for this token
  • Uses the wiremock crate to mock the OpenAI API: parse the openai request, lookup the response in assets, craft an openai response

@dureuill dureuill requested a review from irevoire July 31, 2024 13:28
@dureuill dureuill changed the base branch from main to release-v1.10.0 July 31, 2024 13:29
@dureuill dureuill added this to the v1.10.0 milestone Jul 31, 2024
Copy link
Member

@irevoire irevoire left a comment

Choose a reason for hiding this comment

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

Hey, thanks a lot that’s really some awesome tests

bors merge

Comment on lines +112 to +118
let compressed_responses = include_bytes!("openai_tokenized_responses.json.gz");
let mut responses = Vec::new();
let mut decoder = flate2::write::GzDecoder::new(&mut responses);

decoder.write_all(compressed_responses).unwrap();
drop(decoder);
serde_json::from_slice(&responses).unwrap()
Copy link
Member

Choose a reason for hiding this comment

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

We may consider putting an on-disk cache on this part if it starts taking a lot of time

Comment on lines +1643 to +1648
// test with a server that responds 500 on 3 out of 4 calls
#[actix_rt::test]
async fn it_still_works() {
let (_mock, setting) = create_fallible_mock().await;
let server = get_server_vector().await;
let index = server.index("doggo");
Copy link
Member

Choose a reason for hiding this comment

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

That's a very nice test tbh
It’s awesome you did it

meili-bors bot added a commit that referenced this pull request Aug 5, 2024
4846: Add OpenAI tests r=irevoire a=dureuill

# Pull Request

## Related issue
Part of fixing #4757 

## What does this PR do?
- OpenAI embedder: don't pass apiKey when it is empty (slightly improves error messages)
- rest embedder and rest-based embedders: specialize the authorization denied error message depending on the configuration source
- fix existing tests
- Adds assets containing prerecorded texts to embed and the embeddings obtained from OpenAI
- Adds an asset containing a tokenized long document and the embedding obtained from OpenAI for this token
- Uses the wiremock crate to mock the OpenAI API: parse the openai request, lookup the response in assets, craft an openai response


Co-authored-by: Louis Dureuil <[email protected]>
Copy link
Contributor

meili-bors bot commented Aug 5, 2024

Build failed:

@dureuill
Copy link
Contributor Author

dureuill commented Aug 5, 2024

bors merge

Copy link
Contributor

meili-bors bot commented Aug 5, 2024

Build succeeded:

@meili-bors meili-bors bot merged commit 57f7af7 into release-v1.10.0 Aug 5, 2024
10 checks passed
@meili-bors meili-bors bot deleted the improve-vector-tests branch August 5, 2024 11:24
@meili-bot meili-bot added the v1.10.0 PRs/issues solved in v1.10.0 released on 2024-08-26 label Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v1.10.0 PRs/issues solved in v1.10.0 released on 2024-08-26
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants