-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add OpenSearchExt * Update docker-compose.yml * Update OpenSearchAuth.jl * Update chunks_index_schema.json * Update OpenSearchExt.jl * doc: added a page about OpenSearch * README: fixed a dev documentation label --------- Co-authored-by: Egor Shmorgun <egor.shmorgun@opensesame.com>
- Loading branch information
Showing
13 changed files
with
516 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ Manifest.toml | |
/docs/build/ | ||
/docs/Manifest.toml | ||
debug_out | ||
|
||
envs* | ||
|
||
# VS Code | ||
.vscode/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: '3' | ||
services: | ||
opensearch-node: # This is also the hostname of the container within the Docker network (i.e. https://opensearch-node1/) | ||
image: opensearchproject/opensearch:latest # Specifying the latest available image - modify if you want a specific version | ||
container_name: opensearch-node | ||
environment: | ||
- discovery.type=single-node | ||
- plugins.security.disabled=true | ||
ports: | ||
- 9200:9200 # REST API | ||
- 9600:9600 # Performance Analyzer | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# OpenSearch as a vector storage | ||
|
||
OpenSearch is a search application licensed under Apache 2.0 and available as a cloud solution on AWS. OpenSearch can be installed in [a number of ways](https://opensearch.org/downloads.html). But the easiest way to have it locally without authentication is to use Docker. | ||
|
||
Use our [compose-script](docker-compose.yml) and run the following command in a terminal: | ||
|
||
docker-compose up | ||
|
||
If you want to configure a cluster [see full instructions](https://opensearch.org/docs/latest/install-and-configure/index/) | ||
|
||
To enable OpenSearch use: | ||
```bash | ||
export DATASTORE=OPENSEARCH | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
# Vector storage service providers | ||
|
||
The plugin uses a vector storage to store the calculated embedding vectors and doing approximate search. | ||
|
||
The plugin can use any storage if it provides it: | ||
- Store vectors up to 2k in size (for OpenAI embeddings); | ||
- Add and remove records by a string ID with a vector and metadata; | ||
- Do an approximate vector search with a distance score. | ||
|
||
See the current implementations of the storage interfaces if you want to create a new one. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module OpenSearchAuth | ||
|
||
using HTTP | ||
using AWS | ||
using Dates | ||
using TimeZones | ||
|
||
const AWS_REQUEST_HEADERS = ["Host", "Content-Type", "User-Agent"] | ||
const AWS_AUTH_HEADERS = ["Authorization", "Content-MD5", "x-amz-date", "x-amz-security-token"] | ||
|
||
const ES_SERVICE_NAME = "es" | ||
# TODO: add a mechanism for configuring a region of deployment for the instance | ||
const ES_REGION = "us-west-1" | ||
|
||
const ACCEPT_HEADER_KEY = "Accept" | ||
|
||
function auth_layer(handler) | ||
return function (req; auth_params::AWSCredentials, kw...) | ||
config = AWSConfig(;creds=auth_params, region=ES_REGION) | ||
|
||
headers = Dict{String,String}(req.headers) | ||
# With accept header AWS return error about mismatch signature | ||
accept_header = pop!(headers, ACCEPT_HEADER_KEY, nothing) | ||
|
||
aws_request = AWS.Request( | ||
content=req.body.s, | ||
url=string(req.url), | ||
headers=headers, | ||
api_version="none", | ||
request_method=req.method, | ||
service=ES_SERVICE_NAME | ||
) | ||
AWS.sign_aws4!(config, aws_request, now(UTC)) | ||
|
||
if !isnothing(accept_header) | ||
aws_request.headers[ACCEPT_HEADER_KEY] = accept_header | ||
end | ||
|
||
req.headers = collect(aws_request.headers) | ||
|
||
return handler(req; kw...) | ||
end | ||
end | ||
|
||
HTTP.@client [auth_layer] | ||
|
||
end |
Oops, something went wrong.