From 961d02b5147a48dff72620852776c2f87c9a9ef8 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 26 Nov 2025 07:21:57 +0000 Subject: [PATCH 1/3] Fix malformed OpenAI API response format in tests Fixed test/preparation.jl line 68 where the embedding response was incorrectly formatted as a single dictionary with a 2D matrix instead of separate dictionaries with 1D vectors. This was causing CI failures after upgrading to PromptingTools v0.84+, which has stricter validation of API response formats. Changed from: - Dict(:embedding => ones(128, 2)) - single dict with 128x2 matrix To: - [Dict(:embedding => ones(Float32, 128)), Dict(:embedding => ones(Float32, 128))] - two dicts with 128-dim vectors This matches the correct OpenAI API format where each embedding is returned as a separate object in the data array. --- test/preparation.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) From 0aaa8ccab9a48c0db0d413b0523d1173e06ff252 Mon Sep 17 00:00:00 2001 From: svilupp Date: Thu, 27 Nov 2025 11:40:56 -0600 Subject: [PATCH 2/3] set mock key for testing --- test/runtests.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 7917cdb..3f35886 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,6 +9,10 @@ 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 +ENV["OPENAI_API_KEY"] = get(ENV, "OPENAI_API_KEY", "test-api-key-for-mock-server") + @testset "RAGTools.jl" begin @testset "Code quality (Aqua.jl)" begin Aqua.test_all(RAGTools) From 2612f9f436fdec17cb2b878adada78ad7baee9be Mon Sep 17 00:00:00 2001 From: svilupp Date: Thu, 27 Nov 2025 11:41:20 -0600 Subject: [PATCH 3/3] key for testing --- test/runtests.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 3f35886..ade0051 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -11,7 +11,10 @@ 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 -ENV["OPENAI_API_KEY"] = get(ENV, "OPENAI_API_KEY", "test-api-key-for-mock-server") +# 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