Skip to content

Commit f8a6994

Browse files
authored
Fix embeddings api_key (#31)
1 parent 1114523 commit f8a6994

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
## [0.10.0]
1414

1515
### Updated
16-
- Increased compat for PromptingTools to v0.85
16+
- Moved up compat for PromptingTools to v0.87 (fixing api key bug for embedding models)
17+
18+
### Fixed
19+
- Fixed mock embedding response in the tests
1720

1821
## [0.9.0]
1922

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ HTTP = "1.10.15"
2929
JSON3 = "1.14.1"
3030
LinearAlgebra = "1"
3131
ProgressMeter = "1.10"
32-
PromptingTools = "0.84 - 0.85"
32+
PromptingTools = "0.87"
3333
Random = "1"
3434
Snowball = "0.1"
3535
SparseArrays = "1"

test/preparation.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ end
6565
@test_throws AssertionError get_embeddings(BitPackedBatchEmbedder(), String[])
6666

6767
# corresponds to OpenAI API v1
68-
response1 = Dict(:data => [Dict(:embedding => ones(128, 2))],
68+
response1 = Dict(
69+
:data => [Dict(:embedding => ones(Float32, 128)),
70+
Dict(:embedding => ones(Float32, 128))],
6971
:usage => Dict(:total_tokens => 2, :prompt_tokens => 2, :completion_tokens => 0))
7072
schema = TestEchoOpenAISchema(; response = response1, status = 200)
7173
PT.register_model!(; name = "mock-emb", schema)

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ using Aqua
99
const PT = PromptingTools
1010
const RT = RAGTools
1111

12+
# Set a dummy API key for tests using CustomOpenAISchema with mock HTTP servers
13+
# Required since OpenAI.jl now throws an error when api_key is empty
14+
# We set the PT global directly since it's loaded at module load time from preferences/ENV
15+
if isempty(PT.OPENAI_API_KEY)
16+
PT.OPENAI_API_KEY = "test-api-key-for-mock-server"
17+
end
18+
1219
@testset "RAGTools.jl" begin
1320
@testset "Code quality (Aqua.jl)" begin
1421
Aqua.test_all(RAGTools)

0 commit comments

Comments
 (0)