Skip to content

Commit 9227128

Browse files
Merge pull request #9 from hummusonrails/add-more
Search with local embedding option and update README
2 parents 94faa11 + fafa096 commit 9227128

File tree

5 files changed

+1765
-38
lines changed

5 files changed

+1765
-38
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,46 @@ You can perform a santity check to ensure the index was created by querying for
179179
180180
```bash
181181
> query indexes
182+
```
183+
184+
## Search Data
185+
186+
Now that the data has been indexed, you can perform similarity searches using the vector search index.
187+
188+
You can use the `/search` endpoint provided in this repository to search for similar items based on a query item. The endpoint will return the top 5 most similar items.
189+
190+
The Codespace environment already has all the dependencies installed. You can start the Express.js application by running the following command:
191+
192+
```bash
193+
node server.js
194+
```
195+
196+
Once the server is running, you can either search using the provided query with the embedding already generated or you can provide your own query item.
197+
198+
### Search with the provided query
199+
200+
You can search for similar items based on the provided query item by making a POST request to the `/search` endpoint.
201+
202+
Here is an example cURL command to search for similar items based on the provided query item:
203+
204+
```bash
205+
curl -X POST http://localhost:3000/search \
206+
-H "Content-Type: application/json" \
207+
-d '{"q": "", "useLocalEmbedding": true}'
208+
```
209+
210+
As you can see, we use the `useLocalEmbedding` flag to indicate that we want to use the provided query item and we keep the `q` field empty.
211+
212+
### Search with your own query
213+
214+
If you want to search for similar items based on your own query item, you can provide the query item in the request body.
215+
216+
The query will be automatically converted into a vector embedding using the OpenAI API. You need to provide your OpenAI API key in the `.env` file before starting the Express.js application.
217+
218+
Here is an example cURL command to search for similar items based on your own query item:
219+
220+
```bash
221+
curl -X POST http://localhost:3000/search \
222+
-H "Content-Type: application/json" \
223+
-d '{"q": "your_query_item"}'
182224
```

0 commit comments

Comments
 (0)