{"id":19932334,"url":"https://github.com/adamwulf/vectordatabase","last_synced_at":"2025-07-17T10:38:47.912Z","repository":{"id":247850646,"uuid":"810578577","full_name":"adamwulf/VectorDatabase","owner":"adamwulf","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-10T21:21:33.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-11T11:18:19.672Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adamwulf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"adamwulf","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2024-06-05T01:12:13.000Z","updated_at":"2025-05-31T15:39:14.000Z","dependencies_parsed_at":"2024-07-11T01:10:17.099Z","dependency_job_id":null,"html_url":"https://github.com/adamwulf/VectorDatabase","commit_stats":null,"previous_names":["adamwulf/vectordatabase"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adamwulf/VectorDatabase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamwulf%2FVectorDatabase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamwulf%2FVectorDatabase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamwulf%2FVectorDatabase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamwulf%2FVectorDatabase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adamwulf","download_url":"https://codeload.github.com/adamwulf/VectorDatabase/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamwulf%2FVectorDatabase/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265596158,"owners_count":23794846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T23:09:50.496Z","updated_at":"2025-07-17T10:38:47.892Z","avatar_url":"https://github.com/adamwulf.png","language":"Swift","funding_links":["https://github.com/sponsors/adamwulf"],"categories":[],"sub_categories":[],"readme":"# VectorDatabase\n\n`VectorDatabase` is a Swift library for embedding and storing text data using SQLite and USearch. It provides functionality to insert, lookup, and search text embeddings.\n\n## Installation\n\nTo use `VectorDatabase` in your project, add the following dependency to your `Package.swift` file:\n\n```swift\n.package(url: \"https://github.com/adamwulf/VectorDatabase\", .branch(\"main\"))\n```\n\nThen, run `swift package update` to fetch the package.\n\n## Usage\n\n### Importing the Library\n\nTo use `VectorDatabase`, import it at the top of your Swift file:\n\n```swift\nimport VectorDatabase\n```\n\n### Initializing the Database\n\nCreate an instance of `VectorDatabase` by specifying the path where the database files will be stored:\n\n```swift\ndo {\n    let vectorDB = try VectorDatabase(at: \"/path/to/database\")\n} catch {\n    print(\"Failed to initialize VectorDatabase: \\(error)\")\n}\n```\n\n### Inserting Text\n\nInsert text into the database and get a unique key for the text:\n\n```swift\ndo {\n    let key = try await vectorDB.insert(text: \"example text\")\n    print(\"Inserted text with key: \\(key)\")\n} catch {\n    print(\"Failed to insert text: \\(error)\")\n}\n```\n\n### Looking Up Text\n\nLookup text by its content or by its unique key:\n\n```swift\ndo {\n    let result = try vectorDB.lookup(text: \"example text\")\n    print(\"Found text: \\(result.text), embedding: \\(result.embedding)\")\n} catch {\n    print(\"Text not found: \\(error)\")\n}\n\ndo {\n    let result = try vectorDB.lookup(key: someKey)\n    print(\"Found text: \\(result.text), embedding: \\(result.embedding)\")\n} catch {\n    print(\"Text not found: \\(error)\")\n}\n```\n\n### Searching for Similar Texts\n\nSearch for texts similar to a given text or embedding:\n\n```swift\ndo {\n    let results = try vectorDB.search(text: \"example text\", count: 10)\n    for result in results {\n        print(\"Found key: \\(result.key), distance: \\(result.distance)\")\n    }\n} catch {\n    print(\"Search failed: \\(error)\")\n}\n\ndo {\n    let embedding: [Double] = // some embedding\n    let results = try vectorDB.search(embedding: embedding, count: 10)\n    for result in results {\n        print(\"Found key: \\(result.key), distance: \\(result.distance)\")\n    }\n} catch {\n    print(\"Search failed: \\(error)\")\n}\n```\n\n## Example Command Line Tool\n\nThe package also includes a command line tool `vecdb` for embedding and storing input text into a database. You can use it as follows:\n\n```sh\n$ swift run vecdb --help\n$ swift run vecdb example /path/to/database\n```\n\nThis will prime the database with some example texts and perform a search.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE.md](LICENSE.md) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamwulf%2Fvectordatabase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamwulf%2Fvectordatabase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamwulf%2Fvectordatabase/lists"}