-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: split the package into multiple monorepo packages
- Loading branch information
1 parent
3c38f27
commit b1004e2
Showing
53 changed files
with
5,253 additions
and
5,204 deletions.
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 |
---|---|---|
|
@@ -203,4 +203,6 @@ $RECYCLE.BIN/ | |
|
||
|
||
example/out.js | ||
.vscode | ||
.vscode | ||
|
||
.turbo |
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,30 +1,34 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.4.1/schema.json", | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"formatter": { | ||
"enabled": true, | ||
"lineWidth": 160, | ||
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json", | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"formatter": { | ||
"enabled": true, | ||
"lineWidth": 160, | ||
"indentStyle": "space" | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true, | ||
"style": { | ||
"noNonNullAssertion": "off" | ||
}, | ||
"suspicious": { | ||
"noExplicitAny": "off" | ||
} | ||
} | ||
}, | ||
"javascript": { | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true, | ||
"style": { | ||
"noNonNullAssertion": "off" | ||
}, | ||
"suspicious": { | ||
"noExplicitAny": "off" | ||
} | ||
} | ||
}, | ||
"javascript": { | ||
"formatter": { | ||
"trailingCommas": "none", | ||
"semicolons": "asNeeded", | ||
"trailingComma": "none", | ||
"quoteStyle": "single" | ||
} | ||
}, | ||
"files": { | ||
"include": ["apps/**", "packages/**"], | ||
"ignore": ["**/dist/**", "**/node_modules/**"] | ||
} | ||
} | ||
} |
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,90 +1,29 @@ | ||
{ | ||
"name": "@oramacloud/client", | ||
"name": "@oramacloud/oramacloud-monorepo", | ||
"version": "1.3.20", | ||
"description": "Orama SDK for Node.js, Deno, and Browsers", | ||
"type": "module", | ||
"sideEffects": false, | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"runkitExampleFilename": "./example/runkit.js", | ||
"exports": { | ||
".": { | ||
"require": "./dist/index.cjs", | ||
"import": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"browser": "./dist/index.global.js" | ||
}, | ||
"./react": { | ||
"require": "./dist/react/index.cjs", | ||
"import": "./dist/react/index.js", | ||
"types": "./dist/react/index.d.ts" | ||
}, | ||
"./vue": { | ||
"require": "./dist/vue/index.cjs", | ||
"import": "./dist/vue/index.js", | ||
"types": "./dist/vue/index.d.ts" | ||
} | ||
}, | ||
"workspaces": ["packages/*"], | ||
"scripts": { | ||
"format": "bunx @biomejs/biome format src --write", | ||
"build": "npm run build:lib && npm run build:react && npm run build:vue", | ||
"dev": "run-p watch:lib watch:react watch:vue", | ||
"watch:lib": "tsup --config tsup.lib.js --watch src", | ||
"watch:react": "tsup --config tsup.react.js --watch", | ||
"watch:vue": "tsup --config tsup.vue.js --watch", | ||
"build:lib": "tsup --config tsup.lib.js", | ||
"build:react": "tsup --config tsup.react.js", | ||
"build:vue": "tsup --config tsup.vue.js", | ||
"test": "glob -c \"node --import tsx --no-warnings --test\" \"./tests/**/*.test.ts\"", | ||
"serve:example": "esbuild src/index.ts --bundle --outfile=example/out.js --format=esm --watch --servedir=example", | ||
"prepare": "husky install" | ||
"test": "turbo test", | ||
"lint": "biome ci", | ||
"biome:check": "biome check --write", | ||
"build": "turbo build --no-cache" | ||
}, | ||
"keywords": [ | ||
"orama", | ||
"search engine", | ||
"sdk" | ||
], | ||
"files": [ | ||
"dist", | ||
"example/runkit.js" | ||
], | ||
"keywords": ["orama", "search engine", "sdk"], | ||
"author": { | ||
"name": "Michele Riva", | ||
"email": "[email protected]", | ||
"url": "https://github.com/MicheleRiva" | ||
}, | ||
"license": "ISC", | ||
"dependencies": { | ||
"@orama/cuid2": "^2.2.3", | ||
"@orama/orama": "^2.0.16", | ||
"lodash": "^4.17.21", | ||
"openai": "^4.24.1", | ||
"react": "^18.2.0", | ||
"vue": "^3.4.25" | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "1.8.1", | ||
"@fastify/formbody": "^7.4.0", | ||
"@types/lodash": "^4.14.202", | ||
"@types/node": "^20.3.1", | ||
"@types/react": "^18.2.14", | ||
"dotenv": "^16.3.1", | ||
"esbuild": "0.18.5", | ||
"fastify": "^4.19.2", | ||
"glob": "^11.0.0", | ||
"husky": "^8.0.3", | ||
"npm-run-all": "^4.1.5", | ||
"ts-standard": "^12.0.2", | ||
"tsup": "^8.3.0", | ||
"tsx": "^4.7.0", | ||
"typescript": "^5.1.3" | ||
"@biomejs/biome": "^1.9.4", | ||
"turbo": "^2.1.1" | ||
}, | ||
"ts-standard": { | ||
"ignore": [ | ||
"dist", | ||
"node_modules" | ||
] | ||
"ignore": ["dist", "node_modules"] | ||
}, | ||
"packageManager": "[email protected]+sha512.73a29afa36a0d092ece5271de5177ecbf8318d454ecd701343131b8ebc0c1a91c487da46ab77c8e596d6acf1461e3594ced4becedf8921b074fbd8653ed7051c" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,196 @@ | ||
# Orama Cloud Client | ||
|
||
[![Node.js CI](https://github.com/askorama/javascript-sdk/actions/workflows/node.js.yml/badge.svg)](https://github.com/askorama/javascript-sdk/actions/workflows/node.js.yml) | ||
|
||
## Install | ||
|
||
```sh | ||
npm i @oramacloud/client | ||
``` | ||
|
||
## Integrating with Orama Cloud | ||
|
||
```js | ||
import { OramaClient } from "@oramacloud/client"; | ||
|
||
const client = new OramaClient({ | ||
endpoint: "<Your Orama Cloud Endpoint>", | ||
api_key: "<Your Orama Cloud API Key>", | ||
}); | ||
|
||
const results = await client.search({ | ||
term: "red leather shoes", | ||
}); | ||
``` | ||
|
||
## Advanced search | ||
|
||
```js | ||
const results = await client.search({ | ||
term: "red leather shoes", | ||
where: { | ||
price: { | ||
lte: 9.99, | ||
}, | ||
gender: "unisex", | ||
}, | ||
limit: 5, | ||
offset: 1, | ||
}); | ||
``` | ||
|
||
## Generating embeddings via the Secure Proxy | ||
|
||
```js | ||
import { OramaProxy } from "@oramacloud/client"; | ||
|
||
const proxy = new OramaProxy({ | ||
api_key: "<Your Orama Secure Proxy API Key>", | ||
}); | ||
|
||
const embeddings = await proxy.generateEmbeddings( | ||
"red leather shoes", | ||
"openai/text-embedding-ada-002" | ||
); | ||
|
||
console.log(embeddings); | ||
// [-0.019633075, -0.00820422, -0.013555876, -0.011825735, 0.006641511, -0.012948156, ...] | ||
``` | ||
|
||
Available models: | ||
|
||
- `orama/gte-small`. 384 dimensions, operated by Orama Cloud (preferred) | ||
- `orama/gte-medium`. 768 dimensions, operated by Orama Cloud | ||
- `orama/gte-large`. 1024 dimensions, operated by Orama Cloud | ||
- `openai/text-embedding-ada-002`. 1536 dimensions, proxied to OpenAI | ||
- `openai/text-embedding-3-small`. 1536 dimensions, proxied to OpenAI | ||
- `openai/text-embedding-3-large`. 3072 dimensions, proxied to OpenAI | ||
|
||
## Generating chat completions via the Secure Proxy | ||
|
||
You can generate chat completions via the Secure Proxy in two different ways: | ||
|
||
### Returning a single string | ||
|
||
```js | ||
import { OramaProxy } from "@oramacloud/client"; | ||
|
||
const proxy = new OramaClient({ | ||
api_key: "<Your Orama Secure Proxy API Key>", | ||
}); | ||
|
||
const chatParams = { | ||
model: "openai/gpt-4", | ||
messages: [{ role: "user", content: "Who is Michael Scott?" }], | ||
}; | ||
|
||
const response = await proxy.chat(chatParams); | ||
console.log(response); | ||
|
||
// "Michael Scott is a fictional character from the television show "The Office" (US version) ..." | ||
``` | ||
|
||
Available models: | ||
|
||
- `openai/gpt-4o` | ||
- `openai/gpt-4o-mini` | ||
- `openai/gpt-4-turbo` | ||
- `openai/gpt-4` | ||
- `openai/gpt-3.5-turbo` | ||
|
||
### Returning a stream (via async iterators) | ||
|
||
```js | ||
import { OramaProxy } from "@oramacloud/client"; | ||
|
||
const proxy = new OramaClient({ | ||
api_key: "<Your Orama Secure Proxy API Key>", | ||
}); | ||
|
||
const chatParams = { | ||
model: "openai/gpt-4", | ||
messages: [{ role: "user", content: "Who is Michael Scott?" }], | ||
}; | ||
|
||
for await (const message of proxy.chatStream(chatParams)) { | ||
console.log(message); | ||
} | ||
|
||
// Michael | ||
// Scott is | ||
// a fictional | ||
// character from the | ||
// television show | ||
// "The | ||
// Office" (US | ||
// version) | ||
// ... | ||
``` | ||
|
||
Available models: | ||
|
||
- `openai/gpt-4o` | ||
- `openai/gpt-4o-mini` | ||
- `openai/gpt-4-turbo` | ||
- `openai/gpt-4` | ||
- `openai/gpt-3.5-turbo` | ||
|
||
## Identifying users | ||
|
||
### Usage with browsers | ||
|
||
1. Call the `.identify()` method with the user's unique identifier. | ||
2. Call `.reset()` when users log out. | ||
|
||
Note: we suggest developers to always call `.identify()` when users sign-up, log-in or when the user re-opens the application in a logged-in state. | ||
|
||
Example or already logged in state: | ||
|
||
```js | ||
|
||
import { OramaClient } from "@oramacloud/client"; | ||
|
||
const client = new OramaClient({ | ||
endpoint: "<Your Orama Cloud Endpoint>", | ||
api_key: "<Your Orama Cloud API Key>", | ||
}); | ||
|
||
client.identify("<Your unique User ID>"); | ||
|
||
client.search({ | ||
term: "red leather shoes", | ||
}); | ||
``` | ||
|
||
Upon logging out: | ||
|
||
```js | ||
client.reset(); | ||
``` | ||
|
||
### Usage with server-side applications | ||
|
||
1. Call the `.identify()` method with the user's unique identifier. | ||
2. Call `.reset()` when users log out. | ||
|
||
OramaClient will always generate a new userId upon **initialization**, so we suggest developers to call the `.reset()` function even when users are not necessarily identified. This will ensure that the client is not associated with the previous user, thus preventing improper data association between sessions. | ||
|
||
### Usage of Alias | ||
|
||
Aliases are employed to link multiple identifiers to a single user, enabling the tracking of anonymous users across different sessions. This is particularly beneficial for monitoring users who are not logged in or who access the platform from various devices. | ||
|
||
```js | ||
import { OramaClient } from "@oramacloud/client"; | ||
|
||
const client = new OramaClient({ | ||
endpoint: "<Your Orama Cloud Endpoint>", | ||
api_key: "<Your Orama Cloud API Key>", | ||
}); | ||
|
||
// Sets the alias for the current user | ||
client.alias("<Unique Alias ID>"); | ||
|
||
client.search({ | ||
term: "red leather shoes", | ||
}); | ||
``` |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.