diff --git a/test/preparation.jl b/test/preparation.jl index b55122c..e77f41c 100644 --- a/test/preparation.jl +++ b/test/preparation.jl @@ -65,7 +65,8 @@ end @test_throws AssertionError get_embeddings(BitPackedBatchEmbedder(), String[]) # corresponds to OpenAI API v1 - response1 = Dict(:data => [Dict(:embedding => ones(128, 2))], + response1 = Dict(:data => [Dict(:embedding => ones(Float32, 128)), + Dict(:embedding => ones(Float32, 128))], :usage => Dict(:total_tokens => 2, :prompt_tokens => 2, :completion_tokens => 0)) schema = TestEchoOpenAISchema(; response = response1, status = 200) PT.register_model!(; name = "mock-emb", schema) diff --git a/test/runtests.jl b/test/runtests.jl index 7917cdb..ade0051 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,6 +9,13 @@ using Aqua const PT = PromptingTools const RT = RAGTools +# Set a dummy API key for tests using CustomOpenAISchema with mock HTTP servers +# Required since OpenAI.jl now throws an error when api_key is empty +# We set the PT global directly since it's loaded at module load time from preferences/ENV +if isempty(PT.OPENAI_API_KEY) + PT.OPENAI_API_KEY = "test-api-key-for-mock-server" +end + @testset "RAGTools.jl" begin @testset "Code quality (Aqua.jl)" begin Aqua.test_all(RAGTools)