File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed
fern_documentation/python Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 1- import argparse
1+ import argparse
22
33from compass_sdk_examples .utils import get_compass_api
44
Original file line number Diff line number Diff line change 1+ import os
2+
3+ from cohere .compass .clients import CompassClient
4+
5+ compass_client = CompassClient (index_url = os .getenv ("COMPASS_API_URL" ), bearer_token = os .getenv ("COMPASS_API_BEARER_TOKEN" ))
6+ r = compass_client .create_index (index_name = "my_index" )
7+ if r .error :
8+ raise Exception (f"Failed to create indexes: { r .error } " )
9+
Original file line number Diff line number Diff line change 1+ import os
2+
3+ from cohere .compass .clients import CompassClient
4+
5+ compass_client = CompassClient (index_url = os .getenv ("COMPASS_API_URL" ), bearer_token = os .getenv ("COMPASS_API_BEARER_TOKEN" ))
6+ r = compass_client .list_indexes ()
7+ if r .error :
8+ raise Exception (f"Failed to list indexes: { r .error } " )
9+
10+ indexes = r .result ['indexes' ]
11+ for index in indexes :
12+ print (f"Index name: { index ['name' ]} " )
13+ print (f"Chunk counts: { index ['count' ]} " )
14+ print (f"Document counts: { index ['parent_doc_count' ]} " )
You can’t perform that action at this time.
0 commit comments