Skip to content

Commit

Permalink
feat: add preview vector index client (#710)
Browse files Browse the repository at this point in the history
* feat: adding preview vector index client

Co-authored-by: Michael Landis <[email protected]>
Co-authored-by: Chris Price <[email protected]>
  • Loading branch information
3 people authored Aug 30, 2023
1 parent 3ccbfff commit f1721cc
Show file tree
Hide file tree
Showing 28 changed files with 66,830 additions and 4,820 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
async function example_API_CreateIndex(vectorClient: PreviewVectorClient) {
const result = await vectorClient.createIndex('test-index');
if (result instanceof CreateIndex.Success) {
console.log("Index 'test-index' created");
} else if (result instanceof CreateIndex.AlreadyExists) {
console.log("Index 'test-index' already exists");
} else if (result instanceof CreateIndex.Error) {
throw new Error(
`An error occurred while attempting to create index 'test-index': ${result.errorCode()}: ${result.toString()}`
);
}
}

async function example_API_ListIndexes(vectorClient: PreviewVectorClient) {
const result = await vectorClient.listIndexes();
if (result instanceof ListIndexes.Success) {
console.log(
`Indexes:\n${result
.getIndexNames()
.join('\n')}\n\n`
);
} else if (result instanceof ListIndexes.Error) {
throw new Error(`An error occurred while attempting to list caches: ${result.errorCode()}: ${result.toString()}`);
}
}

async function example_API_DeleteIndex(vectorClient: PreviewVectorClient) {
const result = await vectorClient.deleteIndex("test-index")
if (result instanceof DeleteIndex.Success) {
console.log("Index 'test-index' deleted");
} else if (result instanceof DeleteIndex.Error) {
throw new Error(
`An error occurred while attempting to delete index 'test-index': ${result.errorCode()}: ${result.toString()}`
);
}
}
Loading

0 comments on commit f1721cc

Please sign in to comment.