Skip to content

Commit

Permalink
Feature/dev rebased (#1500)
Browse files Browse the repository at this point in the history
* Feature/move logging (#1493)

* move logging provider out

* move logging provider to own directory, remove singleton

* cleanup

* Update js package (#1498)

* fix refactoring tweak (#1496)

* Fix JSON serialization and Prompt ID Bugs for Prompts (#1491)

* Bug in get prompts

* Add tests

* Prevent verbose logging on standup

* Remove kg as required key in config, await get_all_prompts

* Remove reference to fragment id

* comment out ingestion

* complete logging port (#1499)

---------

Co-authored-by: Nolan Tremelling <[email protected]>
  • Loading branch information
emrgnt-cmplxty and NolanTrem authored Oct 25, 2024
1 parent d4a8047 commit b19bb97
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 80 deletions.
2 changes: 1 addition & 1 deletion js/sdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "r2r-js",
"version": "0.3.10",
"version": "0.3.11",
"description": "",
"main": "dist/index.js",
"browser": "dist/index.browser.js",
Expand Down
154 changes: 76 additions & 78 deletions js/sdk/src/r2rClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1629,90 +1629,88 @@ export class r2rClient {
responseType: "stream",
});
}
/**
* Create a vector index for similarity search.
* @param options The options for creating the vector index
* @returns Promise resolving to the creation response
*/
@feature("createVectorIndex")
async createVectorIndex(options: {
tableName: string;
indexMethod: "hnsw" | "ivfflat" | "auto";
indexMeasure: "cosine_distance" | "l2_distance" | "max_inner_product";
indexArguments?: {
m?: number; // HNSW: Number of connections per element
ef_construction?: number;// HNSW: Size of dynamic candidate list
n_lists?: number; // IVFFlat: Number of clusters/inverted lists
};
indexName?: string;
concurrently?: boolean;
}): Promise<Record<string, any>> {
this._ensureAuthenticated();

const data = {
table_name: options.tableName,
index_method: options.indexMethod,
index_measure: options.indexMeasure,
index_arguments: options.indexArguments,
index_name: options.indexName,
concurrently: options.concurrently ?? true
};

return await this._makeRequest("POST", "create_vector_index", {
data,
headers: {
"Content-Type": "application/json"
}
});
}
/**
* Create a vector index for similarity search.
* @param options The options for creating the vector index
* @returns Promise resolving to the creation response
*/
@feature("createVectorIndex")
async createVectorIndex(options: {
tableName: string;
indexMethod: "hnsw" | "ivfflat" | "auto";
indexMeasure: "cosine_distance" | "l2_distance" | "max_inner_product";
indexArguments?: {
m?: number; // HNSW: Number of connections per element
ef_construction?: number; // HNSW: Size of dynamic candidate list
n_lists?: number; // IVFFlat: Number of clusters/inverted lists
};
indexName?: string;
concurrently?: boolean;
}): Promise<Record<string, any>> {
this._ensureAuthenticated();

const data = {
table_name: options.tableName,
index_method: options.indexMethod,
index_measure: options.indexMeasure,
index_arguments: options.indexArguments,
index_name: options.indexName,
concurrently: options.concurrently ?? true,
};

/**
* List existing vector indices for a table.
* @param options The options for listing vector indices
* @returns Promise resolving to the list of indices
*/
@feature("listVectorIndices")
async listVectorIndices(options: {
tableName?: string;
}): Promise<Record<string, any>> {
this._ensureAuthenticated();

const params: Record<string, string> = {};
if (options.tableName) {
params.table_name = options.tableName;
return await this._makeRequest("POST", "create_vector_index", {
data,
headers: {
"Content-Type": "application/json",
},
});
}

return await this._makeRequest("GET", "list_vector_indices", { params });
}
/**
* List existing vector indices for a table.
* @param options The options for listing vector indices
* @returns Promise resolving to the list of indices
*/
@feature("listVectorIndices")
async listVectorIndices(options: {
tableName?: string;
}): Promise<Record<string, any>> {
this._ensureAuthenticated();

/**
* Delete a vector index from a table.
* @param options The options for deleting the vector index
* @returns Promise resolving to the deletion response
*/
@feature("deleteVectorIndex")
async deleteVectorIndex(options: {
indexName: string;
tableName?: string;
concurrently?: boolean;
}): Promise<Record<string, any>> {
this._ensureAuthenticated();

const data = {
index_name: options.indexName,
table_name: options.tableName,
concurrently: options.concurrently ?? true
};

return await this._makeRequest("DELETE", "delete_vector_index", {
data,
headers: {
"Content-Type": "application/json"
const params: Record<string, string> = {};
if (options.tableName) {
params.table_name = options.tableName;
}
});
}

}
return await this._makeRequest("GET", "list_vector_indices", { params });
}

/**
* Delete a vector index from a table.
* @param options The options for deleting the vector index
* @returns Promise resolving to the deletion response
*/
@feature("deleteVectorIndex")
async deleteVectorIndex(options: {
indexName: string;
tableName?: string;
concurrently?: boolean;
}): Promise<Record<string, any>> {
this._ensureAuthenticated();

const data = {
index_name: options.indexName,
table_name: options.tableName,
concurrently: options.concurrently ?? true,
};

return await this._makeRequest("DELETE", "delete_vector_index", {
data,
headers: {
"Content-Type": "application/json",
},
});
}
}

export default r2rClient;

0 comments on commit b19bb97

Please sign in to comment.