@@ -4,6 +4,8 @@ description: 'Getting started'
44icon : terminal
55---
66
7+ ## Getting it up and running
8+
791 . Clone the [ repo] ( https://github.com/Eigen-DB/eigen-db ) from GitHub:
810
911``` sh
@@ -25,6 +27,101 @@ You can test the connection to your instance by running:
2527curl http://localhost:8080/api/v1/health
2628```
2729
30+ ## Creating your first index
31+
32+ EigenDB can be interfaced with through our Python SDK or its robust REST API.
33+
34+ <AccordionGroup >
35+ <Accordion title = " Python SDK" >
36+ <Info >
37+ To install the Python SDK, check out this [ page] ( /sdks/python ) .
38+ </Info >
39+
40+ ``` python python
41+ import os
42+ from eigen_client.client import Client
43+ from eigen_client.data_types import Document
44+
45+ client = Client(
46+ url = " http://localhost:8080" ,
47+ api_key = " eigendb-***" ,
48+ )
49+
50+ index = client.create_index_from_model(
51+ index_name = " food-facts" ,
52+ model_name = " text-embedding-3-small" ,
53+ model_provider = " openai" ,
54+ model_provider_api_key = " your openai api key..."
55+ )
56+
57+ documents = [
58+ Document(id = 1 , data = " Fresh herbs boost flavor." , metadata = {" recipe_id" : " 123" }),
59+ Document(id = 2 , data = " Slow simmer blends soup." , metadata = {" recipe_id" : " 456" }),
60+ Document(id = 3 , data = " Homemade bread smells great." , metadata = {" recipe_id" : " 789" }),
61+ Document(id = 4 , data = " Grilled veggies taste sweeter." , metadata = {" recipe_id" : " 987" }),
62+ Document(id = 5 , data = " Cast iron sears steak well." , metadata = {" recipe_id" : " 654" })
63+ ]
64+
65+ index.upsert_docs(documents)
66+
67+ results = index.search_docs(
68+ string = " Baking" ,
69+ k = 3
70+ )
71+
72+ print (results)
73+ ```
74+ </Accordion >
75+ <Accordion title = " REST API" >
76+ To first create an index:
77+
78+ ``` bash curl
79+ curl -X PUT http://localhost:8080/api/v1/indexes/[INDEX-NAME]/create \
80+ -H " Content-Type: application/json" \
81+ -H " X-Eigen-API-Key: eigendb-***" \
82+ -d ' {
83+ "dimensions": 1536,
84+ "metric": "cosine"
85+ }'
86+ ```
87+
88+ To upsert your embeddings:
89+
90+ ``` bash curl
91+ curl -X PUT http://localhost:8080/api/v1/embeddings/[INDEX-NAME]/upsert \
92+ -H " Content-Type: application/json" \
93+ -H " X-Eigen-API-Key: eigendb-***" \
94+ -d ' {
95+ "embeddings": [
96+ {
97+ "id": 1,
98+ "data": [0.1, 0.2, 0.3, ..., 0.384],
99+ "metadata": {"recipe_id": "123"}
100+ },
101+ {
102+ "id": 2,
103+ "data": [0.2, 0.1, 0.4, ..., 0.385],
104+ "metadata": {"recipe_id": "456"}
105+ },
106+ ...
107+ ]
108+ }'
109+ ```
110+
111+ To search for similar embeddings:
112+
113+ ``` bash curl
114+ curl -X POST http://localhost:8080/api/v1/embeddings/[INDEX-NAME]/search \
115+ -H " Content-Type: application/json" \
116+ -H " X-Eigen-API-Key: eigendb-***" \
117+ -d ' {
118+ "queryVector": [0.1, 0.2, 0.3, ..., 0.384],
119+ "k": 3
120+ }'
121+ ```
122+ </Accordion >
123+ </AccordionGroup >
124+
28125{ /*
29126<Info>
30127 **Prerequisite** You should have installed Node.js (version 18.10.0 or
0 commit comments