Skip to content

Commit e850014

Browse files
committed
Adding fern python documentation
1 parent 01269af commit e850014

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

examples/compass_sdk_examples/search_documents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import argparse
1+
import argparse
22

33
from compass_sdk_examples.utils import get_compass_api
44

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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']}")

0 commit comments

Comments
 (0)