Skip to content

Commit

Permalink
fix package json fields, add example pt1
Browse files Browse the repository at this point in the history
  • Loading branch information
erhant committed Feb 2, 2024
1 parent 89e32d1 commit 30f64a0
Show file tree
Hide file tree
Showing 13 changed files with 251 additions and 14 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="./logo.svg" alt="logo" width="142">
<img src="https://raw.githubusercontent.com/firstbatchxyz/dria-js-client/master/logo.svg" alt="logo" width="142">
</p>

<p align="center">
Expand All @@ -11,6 +11,15 @@
</p>
</p>

<p align="center">
<a href="https://opensource.org/licenses/MIT" target="_blank">
<img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-7CB9E8.svg">
</a>
<a href="https://www.npmjs.com/package/dria" target="_blank">
<img alt="NPM" src="https://img.shields.io/npm/v/dria?logo=npm&color=CB3837">
</a>
</p>

DriaJS client is a library & 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.

- [x] Create & manage your knowledge bases on Dria.
Expand Down
175 changes: 175 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore

# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Caches

.cache

# Diagnostic reports (https://nodejs.org/api/report.html)

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
_.pid
_.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
*.lcov

# nyc test coverage

.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)

.grunt

# Bower dependency directory (https://bower.io/)

bower_components

# node-waf configuration

.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)

build/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)

.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store
13 changes: 13 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DriaJS Example

To install dependencies:

```bash
bun install
```

To run:

```bash
bun run index.ts
```
Binary file added example/bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions example/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Dria from "dria";

// TODO: will do example
14 changes: 14 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"private": true,
"module": "index.ts",
"type": "module",
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"dria": "^0.0.1"
}
}
22 changes: 22 additions & 0 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,

/* Linting */
"skipLibCheck": true,
"strict": true,
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true
}
}
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "dria",
"version": "0.0.1",
"author": "FirstBatch Team <dev@firstbatch.xyz>",
"version": "0.0.2",
"license": "Apache-2.0",
"author": "FirstBatch Team <dev@firstbatch.xyz>",
"contributors": [
"Erhan Tezcan <erhan@firstbatch.xyz> (https://github.com/erhant)"
],
Expand All @@ -11,6 +11,10 @@
"LICENSE",
"README.md"
],
"type": "module",
"module": "index.ts",
"main": "build/index.js",
"types": "build/index.d.ts",
"scripts": {
"build": "bun run ./build.ts",
"b": "bun run build",
Expand All @@ -23,8 +27,6 @@
"proto:type": "npx pbts ./proto/insert.js -o ./proto/insert.d.ts",
"proto": "bun proto:code && bun proto:type"
},
"type": "module",
"module": "index.ts",
"dependencies": {
"axios": "^1.6.5",
"zod": "^3.22.4"
Expand Down
2 changes: 1 addition & 1 deletion src/dria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import constants from "./constants";
* dria.contractId = contractId;
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export default class Dria<T extends MetadataType = any> {
export class Dria<T extends MetadataType = any> {
protected client: AxiosInstance;
contractId: string | undefined;
/** Cached contract models. */
Expand Down
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
import Dria from "./dria";
export default Dria;

export { Dria } from "./dria";
export type { DriaParams } from "./types";
2 changes: 1 addition & 1 deletion tests/api.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, describe, it } from "bun:test";
import { randomVector } from "./utils";
import { BatchTexts, BatchVectors } from "../src/schemas";
import Dria from "../src";
import { Dria } from "../src";

describe("API", () => {
// contract of a TypeScript Book uploaded to Dria
Expand Down
2 changes: 1 addition & 1 deletion tests/create.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, describe, it } from "bun:test";
import { randomVector } from "./utils";
import Dria from "../src";
import { BatchVectors } from "../src/schemas";
import { Dria } from "../src";

describe.todo("create knowledge", () => {
type MetadataType = { id: number };
Expand Down
7 changes: 4 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"types": [
"bun-types" // add Bun global
]
}
"bun-types", // add Bun global
],
},
"exclude": ["example", "./build", "./node_modules", "./proto"],
}

0 comments on commit 30f64a0

Please sign in to comment.