Skip to content

Commit

Permalink
[CLN] Apply Prettier Config to JS Client Repo (#1831)
Browse files Browse the repository at this point in the history
## Description of changes

*Summarize the changes made by this PR.*

Applies Prettier formatting to the JS Client Repo and add a presubmit
rule to enforce that behavior.

## Test plan

N/A just formatting changes.
  • Loading branch information
AlabasterAxe authored Mar 13, 2024
1 parent d425111 commit 97c7539
Show file tree
Hide file tree
Showing 34 changed files with 2,430 additions and 2,153 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ repos:
- id: mypy
args: [--strict, --ignore-missing-imports, --follow-imports=silent, --disable-error-code=type-abstract, --config-file=./pyproject.toml]
additional_dependencies: ["types-requests", "pydantic", "overrides", "hypothesis", "pytest", "pypika", "numpy", "types-protobuf", "kubernetes"]


- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
hooks:
- id: prettier
files: "^clients/js/.+"
4 changes: 2 additions & 2 deletions clients/js/examples/browser/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChromaClient } from '../../src/ChromaClient';
import { ChromaClient } from "../../src/ChromaClient";
// import env.ts

window.onload = async () => {
Expand Down Expand Up @@ -27,7 +27,7 @@ window.onload = async () => {
const queryData = await collection.query({
queryEmbeddings: [1, 2, 3, 4, 5],
nResults: 5,
where: { test: "test" }
where: { test: "test" },
});

console.log("queryData", queryData);
Expand Down
20 changes: 11 additions & 9 deletions clients/js/examples/node/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ app.get("/", async (req, res) => {
const cc = new chroma.ChromaClient({ path: "http://localhost:8000" });
await cc.reset();

const google = new chroma.GoogleGenerativeAiEmbeddingFunction({ googleApiKey:"<APIKEY>" });
const google = new chroma.GoogleGenerativeAiEmbeddingFunction({
googleApiKey: "<APIKEY>",
});

const collection = await cc.createCollection({
name: "test-from-js",
Expand All @@ -18,16 +20,16 @@ app.get("/", async (req, res) => {

await collection.add({
ids: ["doc1", "doc2"],
documents: [
"doc1",
"doc2",
]
documents: ["doc1", "doc2"],
});

let count = await collection.count();
console.log("count", count);

const googleQuery = new chroma.GoogleGenerativeAiEmbeddingFunction({ googleApiKey:"<APIKEY>", taskType: 'RETRIEVAL_QUERY' });
const googleQuery = new chroma.GoogleGenerativeAiEmbeddingFunction({
googleApiKey: "<APIKEY>",
taskType: "RETRIEVAL_QUERY",
});

const queryCollection = await cc.getCollection({
name: "test-from-js",
Expand All @@ -36,16 +38,16 @@ app.get("/", async (req, res) => {

const query = await collection.query({
queryTexts: ["doc1"],
nResults: 1
nResults: 1,
});
console.log("query", query);

console.log("COMPLETED");

const collections = await cc.listCollections();
console.log('collections', collections)
console.log("collections", collections);

res.send('Hello World!');
res.send("Hello World!");
});
app.listen(3000, function () {
console.log("Example app listening on port 3000!");
Expand Down
5 changes: 3 additions & 2 deletions clients/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"db:run-auth-xtoken": "cd ../.. && echo \"CHROMA_SERVER_AUTH_TOKEN_TRANSPORT_HEADER=X_CHROMA_TOKEN\nCHROMA_SERVER_AUTH_CREDENTIALS=test-token\nCHROMA_SERVER_AUTH_CREDENTIALS_PROVIDER=chromadb.auth.token.TokenConfigServerAuthCredentialsProvider\nCHROMA_SERVER_AUTH_PROVIDER=chromadb.auth.token.TokenAuthServerProvider\\nCHROMA_PORT=8001\" > .chroma_env && docker-compose -f docker-compose.test-auth.yml --env-file ./.chroma_env up --detach && sleep 5",
"prebuild": "rimraf dist",
"build": "tsup",
"watch": "tsup --watch",
"genapi": "./genapi.sh",
"prettier": "prettier --write .",
"release": "run-s build test:run && npm publish",
Expand All @@ -72,8 +73,8 @@
"node": ">=14.17.0"
},
"dependencies": {
"isomorphic-fetch": "^3.0.0",
"cliui": "^8.0.1"
"cliui": "^8.0.1",
"isomorphic-fetch": "^3.0.0"
},
"peerDependencies": {
"@google/generative-ai": "^0.1.1",
Expand Down
Loading

0 comments on commit 97c7539

Please sign in to comment.