Skip to content

Commit

Permalink
Add method to purge records from namespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
maciekbanas committed Dec 27, 2024
1 parent ddf1ad9 commit ec757eb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: GitAI
Title: Extracts Knowledge From Git Repositories
Version: 0.0.0.9014
Version: 0.0.0.9015
Authors@R: c(
person("Kamil", "Wais", , "[email protected]", role = c("aut", "cre")),
person("Krystian", "Igras", , "[email protected]", role = "aut"),
Expand Down
21 changes: 21 additions & 0 deletions R/Pinecone.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,27 @@ Pinecone <- R6::R6Class(
}

return(record_ids)
},

purge_records = function(ids) {
pinecone_api_key <- Sys.getenv("PINECONE_API_KEY")

url <- paste0("https://", private$.index_host)

body <- list(
ids = ids,
namespace = private$.namespace
)

httr2::request(url) |>
httr2::req_url_path_append("vectors") |>
httr2::req_url_path_append("delete") |>
httr2::req_headers(
"Api-Key" = pinecone_api_key,
"X-Pinecone-API-Version" = "2024-10"
) |>
httr2::req_body_json(body) |>
httr2::req_perform()
}
),

Expand Down
9 changes: 6 additions & 3 deletions inst/example_workflow.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
gitai_demo <- initialize_project("gitai-tests") |>
set_database(index = "gitai-mb",
namespace = "gitai-demo-2") |>
gitai_demo <- initialize_project("gitai-demo-2") |>
set_database(index = "gitai-mb") |>
set_github_repos(
orgs = "r-world-devs"
) |>
Expand All @@ -13,3 +12,7 @@ process_repos(gitai_demo)
gitai_demo$db$find_records("Find package with which I can plot data.")

gitai_demo$db$read_record("GitStats")

record_ids <- gitai_demo$db$list_record_IDs()

gitai_demo$db$purge_records(record_ids)

0 comments on commit ec757eb

Please sign in to comment.