I am first time using weaviate and typsecript as well.
I have set all options in embeded client:
const client: EmbeddedClient = weaviate.client(
new EmbeddedOptions({
port: 7878,
version: '1.18.1',
env: {
QUERY_DEFAULTS_LIMIT: 50,
DEFAULT_VECTORIZER_MODULE: 'text2vec-openai',
},
}),
// weaviate-ts-client ConnectionParams
{
scheme: 'http',
host: '127.0.0.1:7878',
}
);
My question is how do i run the code in ts. I am using visual studio code as editor.
Duda from Weaviate here :)
I have answered this question also in our forums: https://forum.weaviate.io/t/how-to-run-weaviaate/533/2
There is a nice example on how to run Weaviate Embedded here: https://github.com/weaviate/typescript-embedded/tree/main/examples/embedded
Considering you have those files under the same folder, you will need to install the dependencies:
npm i
now transform typescript code into javascript
tsc
and run it:
node dist/idex.js
This is the expected output:
node dist/index.js
Weaviate binary: /home/dudanogueira/.cache/weaviate-embedded-latest
Data path: /home/dudanogueira/.local/share/weaviate
Trying to connect to embedded db... {"errno":-111,"code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":9898}
Started /home/dudanogueira/.cache/weaviate-embedded-latest @ 127.0.0.1:9898 -- process ID 518836
{"action":"startup","default_vectorizer_module":"none","level":"info","msg":"the default vectorizer modules is set to \"none\", as a result all new schema classes without an explicit vectorizer setting, will use this vectorizer","time":"2023-08-14T14:23:27-03:00"}
{"action":"startup","auto_schema_enabled":true,"level":"info","msg":"auto schema enabled setting is set to \"true\"","time":"2023-08-14T14:23:27-03:00"}
{"level":"warning","msg":"Multiple vector spaces are present, GraphQL Explore and REST API list objects endpoint module include params has been disabled as a result.","time":"2023-08-14T14:23:27-03:00"}
{"action":"grpc_startup","level":"info","msg":"grpc server listening at [::]:50051","time":"2023-08-14T14:23:27-03:00"}
{"action":"restapi_management","level":"info","msg":"Serving weaviate at http://127.0.0.1:9898","time":"2023-08-14T14:23:27-03:00"}
connected to embedded db!
Embedded DB started
{"action":"hnsw_vector_cache_prefill","count":1000,"index_id":"wine_Z1lw0YT8yNDP","level":"info","limit":1000000000000,"msg":"prefilled vector cache","time":"2023-08-14T14:23:28-03:00","took":134258}
{
class: 'Wine',
creationTimeUnix: 1692033808364,
id: '43afc241-0846-40ff-a1dc-4f24439f9345',
lastUpdateTimeUnix: 1692033808364,
properties: { description: 'Smooth taste', name: 'Pinot noir' }
}
{
deprecations: null,
objects: [
{
class: 'Wine',
creationTimeUnix: 1692033808364,
id: '43afc241-0846-40ff-a1dc-4f24439f9345',
lastUpdateTimeUnix: 1692033808364,
properties: [Object],
vectorWeights: null
}
],
totalResults: 1
}
{
hostname: 'http://127.0.0.1:9898',
modules: {
'generative-openai': {
documentationHref: 'https://platform.openai.com/docs/api-reference/completions',
name: 'Generative Search - OpenAI'
},
'qna-openai': {
documentationHref: 'https://platform.openai.com/docs/api-reference/completions',
name: 'OpenAI Question & Answering Module'
},
'ref2vec-centroid': {},
'text2vec-cohere': {
documentationHref: 'https://docs.cohere.ai/embedding-wiki/',
name: 'Cohere Module'
},
'text2vec-huggingface': {
documentationHref: 'https://huggingface.co/docs/api-inference/detailed_parameters#feature-extraction-task',
name: 'Hugging Face Module'
},
'text2vec-openai': {
documentationHref: 'https://platform.openai.com/docs/guides/embeddings/what-are-embeddings',
name: 'OpenAI Module'
}
},
version: '1.20.5'
}
Stopping...
Embedded db @ PID 518836 successfully stopped
Exiting...
{"action":"restapi_management","level":"info","msg":"Shutting down... ","time":"2023-08-14T14:23:28-03:00"}
{"action":"restapi_management","level":"info","msg":"Stopped serving weaviate at http://127.0.0.1:9898","time":"2023-08-14T14:23:28-03:00"}
Note: Weaviate Embedded is marked as Experimental as of now.