-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/api delete #14
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f74d1ab
OpenSearch: added 'size' argument to restrict number of docs
os-rss 0e64be4
fixed activation of a storage module
os-rss af2269b
openapi.yaml: added 'delete' endpoint. Re-generated server structures
os-rss 4069e7a
embeddings: api key is not more a global variable
os-rss b02b679
server: added 'delete' endpoint implementation
os-rss 9074d62
tests: added api logic test. + minor refactoring of a mocking part
os-rss a9f7f81
.gitignore: added sysimage
os-rss 058babe
test_api: added comments
os-rss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ Manifest.toml | |
/docs/Manifest.toml | ||
debug_out | ||
envs* | ||
sysimage/ | ||
|
||
# VS Code | ||
.vscode/* | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,63 @@ | ||
# Test storage module for logic check only | ||
module TestStorageExt | ||
using ..DataStore | ||
using ..DataStore: AbstractStorage | ||
|
||
using ...AppServer: | ||
DocumentChunk, | ||
QueryWithEmbedding, QueryResult, | ||
DocumentMetadataFilter, DocumentChunkWithScore, | ||
UpsertResponse | ||
|
||
mutable struct TestStorage <: AbstractStorage | ||
data::Any | ||
data::Vector{String} | ||
|
||
TestStorage() = new([]) | ||
end | ||
create_storage() = TestStorage(nothing) | ||
create_storage() = TestStorage() | ||
|
||
function DataStore.upsert( | ||
storage::TestStorage, | ||
chunks::Dict{String, <:AbstractVector{DocumentChunk}}, | ||
)::UpsertResponse | ||
# add documents ids only into the storage-array | ||
ids = keys(chunks) |> collect | ||
append!(storage.data, ids) | ||
return UpsertResponse(ids = ids) | ||
end | ||
|
||
function DataStore.query( | ||
storage::TestStorage, | ||
queries::AbstractVector{QueryWithEmbedding}, | ||
)::Vector{QueryResult} | ||
isempty(storage.data) && return [] | ||
|
||
# assume the query contains exact document id as we are storing | ||
# Otherwise, we need to implement a real mechanism for calculating embeddings. | ||
return map(queries) do query_with_embedding | ||
text_query = query_with_embedding.query | ||
res = findfirst(s -> isequal(s, text_query), storage.data) | ||
|
||
QueryResult( | ||
query = text_query, | ||
results = isnothing(res) ? [] : [DocumentChunkWithScore(id = text_query, score = 1)], | ||
) | ||
end | ||
end | ||
|
||
function DataStore.delete( | ||
storage::TestStorage; | ||
filter::Vector{DocumentMetadataFilter}, | ||
)::Bool | ||
ids = getfield.(filter, :document_id) | ||
initial_length = length(storage.data) | ||
filter!(i -> i ∉ ids, storage.data) | ||
return initial_length != length(storage.data) | ||
end | ||
|
||
function DataStore.delete_all(storage::TestStorage)::Bool | ||
empty!(storage.data) | ||
return true | ||
end | ||
|
||
end |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there a begin block, is it necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary but logically combines the code