-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
98 additions
and
0 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.venv | ||
__pycache__ | ||
.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# STAPI Weaviate Tutorial | ||
A short tutorial that shows easy it is to use STAPI | ||
(Sentence Transformers API) | ||
with Weaviate by using the text2vec-openai module. | ||
|
||
## Install: Local Docker Compose | ||
Bring up Weaviate and STAPI: | ||
```bash | ||
docker compose up -d | ||
``` | ||
|
||
Create the schema that vectorizes using STAPI endpoint: | ||
``` | ||
curl -X POST \ | ||
-H "Content-Type: application/json" \ | ||
-d @schema.json \ | ||
http://localhost:8080/v1/schema | ||
``` | ||
|
||
Create an object in Weaviate and watch the embedding magic happen: | ||
```bash | ||
curl -X POST \ | ||
-H "Content-Type: application/json" \ | ||
-d @object.json \ | ||
http://localhost:8080/v1/objects?consistency_level=ALL | ||
``` |
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,37 @@ | ||
--- | ||
version: '3.4' | ||
services: | ||
stapi: | ||
image: ghcr.io/substratusai/stapi | ||
environment: | ||
PORT: 8081 | ||
MODEL: multi-qa-MiniLM-L6-cos-v1 | ||
ports: | ||
- 8081:8081 | ||
weaviate: | ||
command: | ||
- --host | ||
- 0.0.0.0 | ||
- --port | ||
- '8080' | ||
- --scheme | ||
- http | ||
image: semitechnologies/weaviate:1.22.0 | ||
links: | ||
- "stapi:stapi" | ||
ports: | ||
- 8080:8080 | ||
volumes: | ||
- weaviate_data:/var/lib/weaviate | ||
restart: on-failure:0 | ||
environment: | ||
QUERY_DEFAULTS_LIMIT: 25 | ||
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' | ||
PERSISTENCE_DATA_PATH: '/var/lib/weaviate' | ||
OPENAI_APIKEY: "not-needed-for-sentence-transformers-api" | ||
DEFAULT_VECTORIZER_MODULE: 'text2vec-openai' | ||
ENABLE_MODULES: 'text2vec-cohere,text2vec-huggingface,text2vec-palm,text2vec-openai,generative-openai,generative-cohere,generative-palm,ref2vec-centroid,reranker-cohere,qna-openai' | ||
CLUSTER_HOSTNAME: 'node1' | ||
volumes: | ||
weaviate_data: | ||
... |
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,7 @@ | ||
{ | ||
"class": "Question", | ||
"properties": { | ||
"question": "Who writes the best LLM tools?", | ||
"answer": "substratus.ai ofcourse" | ||
} | ||
} |
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,27 @@ | ||
{ | ||
"class": "Question", | ||
"description": "A class called document", | ||
"vectorizer": "text2vec-openai", | ||
"moduleConfig": { | ||
"text2vec-openai": { | ||
"model": "davinci", | ||
"baseURL": "http://stapi:8081" | ||
} | ||
}, | ||
"properties": [ | ||
{ | ||
"dataType": [ | ||
"text" | ||
], | ||
"description": "The question", | ||
"name": "question" | ||
}, | ||
{ | ||
"dataType": [ | ||
"text" | ||
], | ||
"description": "The answer", | ||
"name": "answer" | ||
} | ||
] | ||
} |