{"id":19947361,"url":"https://github.com/firstbatchxyz/dria-js-client","last_synced_at":"2025-07-23T13:34:38.679Z","repository":{"id":223249239,"uuid":"743566313","full_name":"firstbatchxyz/dria-js-client","owner":"firstbatchxyz","description":"Permissionless access to AI knowledge as a public good.","archived":false,"fork":false,"pushed_at":"2024-02-26T13:10:10.000Z","size":172,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T13:22:28.070Z","etag":null,"topics":["dria","firstbatch","hollowdb","typescript"],"latest_commit_sha":null,"homepage":"https://dria.co/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/firstbatchxyz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-01-15T14:06:34.000Z","updated_at":"2025-01-10T12:41:19.000Z","dependencies_parsed_at":"2024-02-26T14:29:00.992Z","dependency_job_id":"1d759b07-9bf9-48fc-82a0-776ede22b313","html_url":"https://github.com/firstbatchxyz/dria-js-client","commit_stats":null,"previous_names":["firstbatchxyz/dria-js-client"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/firstbatchxyz/dria-js-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstbatchxyz%2Fdria-js-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstbatchxyz%2Fdria-js-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstbatchxyz%2Fdria-js-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstbatchxyz%2Fdria-js-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/firstbatchxyz","download_url":"https://codeload.github.com/firstbatchxyz/dria-js-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstbatchxyz%2Fdria-js-client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266689281,"owners_count":23969142,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["dria","firstbatch","hollowdb","typescript"],"created_at":"2024-11-13T00:35:46.475Z","updated_at":"2025-07-23T13:34:38.623Z","avatar_url":"https://github.com/firstbatchxyz.png","language":"TypeScript","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/firstbatchxyz/dria-js-client/master/logo.svg\" alt=\"logo\" width=\"142\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003e\n    DriaJS\n  \u003c/h1\u003e\n  \u003cp align=\"center\"\u003e\n    \u003ci\u003eDria JS client.\u003c/i\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://opensource.org/licenses/MIT\" target=\"_blank\"\u003e\n        \u003cimg alt=\"License: MIT\" src=\"https://img.shields.io/badge/license-MIT-7CB9E8.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://www.npmjs.com/package/dria\" target=\"_blank\"\u003e\n        \u003cimg alt=\"NPM\" src=\"https://img.shields.io/npm/v/dria?logo=npm\u0026color=CB3837\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\nDriaJS client is a library \u0026 CLI that integrates [Dria](https://dria.co/) to your application, providing a convenient interface to harness the capabilities of Dria's vector search and retrieval services.\n\n- [x] Create \u0026 manage your knowledge bases on Dria.\n- [x] Make vector based queries, text based searches or fetch vectors by their IDs.\n- [x] Insert vectors \u0026 texts to your existing knowledge.\n- [x] Integrated into [LangChainJS](./examples/langchain/).\n\n## Installation\n\nInstall Dria from NPM:\n\n```sh\nnpm  install dria\nyarn add dria\npnpm add dria\nbun  add dria\n```\n\n## Usage\n\nTo begin, import Dria to your code:\n\n```ts\nimport Dria from \"dria\";\n```\n\n### Queries\n\nWith Dria, you can connect to an existing knowledge uploaded to Dria by providing its contract ID. You can then ask questions to this knowledge, make vector based queries, or directly fetch embeddings with their IDs.\n\n```ts\nconst dria = new Dria({ apiKey, contractId });\n\n// a text-based search\nconst searchRes = await dria.search(\"What is the capital of France?\");\n\n// a vector-based query\nconst queryRes = await dria.query([0.1, 0.2, 0.3]);\n\n// fetch data for specific ids\nconst queryRes = await dria.fetch([0, 1, 2]);\n```\n\n\u003e [!TIP]\n\u003e\n\u003e You can omit the `apiKey`, in which case Dria will look for it at `DRIA_API_KEY` environment variable.\n\n### Inserting Data\n\nYou can insert new data to your existing knowledge, either as batch of texts with metadata or vectors with metadata.\n\n```ts\nconst dria = new Dria({ apiKey, contractId });\n\n// insert raw text, which will be converted to vector embeddings\n// with respect to the model used by this contract\nconst insertTextRes = await dria.insertTexts([\n  { text: \"I am a text.\", metadata: { fromReadme: true } },\n  { text: \"I am another text.\", metadata: { fromReadme: true } },\n]);\n\n// or, compute embeddings on your own and insert the vectors\nconst insertTextRes = await dria.insertTexts([\n  { vector: [0.1, 0.2, 0.3], metadata: { fromReadme: true } },\n  { vector: [0.3, 0.2, 0.1], metadata: { fromReadme: true } },\n]);\n```\n\n### Creating a Knowledge\n\nA new knowledge can be created with Dria client as well. In this example, we omit the `contractId` that was provided to the constructor, since we don't have a contract yet. After deploying a contract, we will set that field manually and we will then be able to call all functions described above so far!\n\n```ts\nconst dria = new Dria({ apiKey });\n\ncontractId = await dria.create(\n  \"My New Contract,\n  \"jina-embeddings-v2-base-en\",\n  \"Science\",\n);\ndria.contractId = contractId;\n```\n\nOur client supports a variety of text embedding models by default:\n\n- OpenAI's Text Embeddings-2 Ada (text-embedding-ada-002)\n- OpenAI's Text Embeddings-3 Small (text-embedding-3-large)\n- OpenAI's Text Embeddings-3 Large (text-embedding-ada-002)\n- Jina's Embeddings V2 Base EN (jina-embeddings-v2-base-en)\n- Jina's Embeddings V2 Small EN (jina-embeddings-v2-small-en)\n\n\u003e [!WARNING]\n\u003e\n\u003e If you provide a different embedding model when creating a contract, you are expected to use those same embeddings models to create vectors from text queries, and call the `query` method.\n\n### Metadata Types\n\nEach knowledge may have a different metadata type, based on the content they were created from. For example, a CSV knowledge will have each column as a separate field in the metadata. You can provide the metadata type as a template parameter so that all methods are type-safe:\n\n```ts\ntype MetadataType = { id: number; foo: string; bar: boolean };\nconst dria = new Dria\u003cMetadataType\u003e();\n\n// metadata is typed as given above\nconst res = dria.fetch([0]);\n```\n\nMetadata type can be overridden for each method as well, if the need may be:\n\n```ts\nconst res = dria.fetch\u003c{ page: number; source: string }\u003e([0]);\n```\n\n## Examples\n\nYou can check out some [examples](./examples/):\n\n- **Simple**: Query a knowledge directly.\n- **Langchain**: Use Dria retriever in an AI agent of [LangChain](https://github.com/langchain-ai/langchainjs/).\n\n## Building\n\nYou can build the library for NPM via:\n\n```sh\nbun run build\nbun b # alias\n```\n\nWe are using Bun's own [bundler](https://bun.sh/docs/bundler).\n\n\u003e [!NOTE]\n\u003e\n\u003e The protobuf files are included in the repo, but they can be generated again via:\n\u003e\n\u003e ```sh\n\u003e bun proto\n\u003e ```\n\n## Testing\n\nFor the tests, you will need an API key at `DRIA_API_KEY` environment variable, which you can provide in an `.env.test` file. You can run tests via:\n\n```sh\nbun run test\nbun t # alias\n```\n\nYou can also specify the test titles (as they appear in `describe`, `it` or `test`).\n\n```sh\nbun t -t \"test-name\"\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirstbatchxyz%2Fdria-js-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirstbatchxyz%2Fdria-js-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirstbatchxyz%2Fdria-js-client/lists"}