Skip to content

Latest commit

 

History

History
195 lines (160 loc) · 5.57 KB

install-weaviate.md

File metadata and controls

195 lines (160 loc) · 5.57 KB

weaviate

Running Weaviate on Red Hat Openshift

My test enviroment

Installation

  1. Install the oc and helm programs on your client workstation.

  2. Login to Openshift and create a new project with a unique name. If you are using the Developer Sandbox for Red Hat Openshift a project will already exist.

To check for the existence of a project run oc project, otherwise use oc new-project to create one.

oc new-project weaviate-bk
PROJ=`oc project -q`
  1. Begin by reviewing the Weaviate Kubernetes Installation docs. As a quick start, use the example helm chart values file in this repo.
  • Configuration options
    • Set your desired api keys by renaming the default values in the example values.yaml file. See lines 153 - 154.
    • You may want to increase the storage size to something larger. See line 88.
    • This example values.yaml enables the following sections:
      • apikey
      • text2vec-huggingface
      • generative-openai
  1. Configure and run the helm installer and wait for the weaviate pod to become ready.
  • Add the weaviate repo to the helm configuration.
helm repo add weaviate https://weaviate.github.io/weaviate-helm
  • Install Weaviate
helm upgrade --install weaviate weaviate/weaviate --namespace ${PROJ} --values ./values.yaml
  1. Expose the Weaviate service as a route
oc create route edge weaviate --service=weaviate --insecure-policy='Redirect'

Testing

export WEAVIATE_URL=https://$(oc get routes weaviate -n ${PROJ} -o jsonpath='{.spec.host}')
curl ${WEAVIATE_URL}

Sample output

{
  "links": {
    "href": "/v1",
    "name": "api v1",
    "documentationHref": "https://weaviate.io/developers/weaviate/current/"
  }
}

Sample Applications

  1. Create a python virtual environment and try a few of the example clients. The first two python examples expect the WEAVIATE_URL and WEAVIATE_API_KEY variables to be set.
python -m venv ~/venv
source ~/venv/bin/activate
cd src
pip install -r requirements.txt
export WEAVIATE_URL=https://$(oc get routes weaviate -n ${PROJ} -o jsonpath='{.spec.host}')
export WEAVIATE_API_KEY='weaviate-api-key-from-values-file-above'
  1. Test the connection with the python sdk.
python 00-test-connection.py 

A shard should be reported for each Weaviate node.

Sample output:

INFO:root:{'batchStats': {'queueLength': 0, 'ratePerSecond': 0}, 'gitHash': '8172acb', 'name': 'weaviate-0', 'shards': None, 'stats': {'objectCount': 0, 'shardCount': 0}, 'status': 'HEALTHY', 'version': '1.21.0'}
INFO:root:
INFO:root:{'batchStats': {'queueLength': 0, 'ratePerSecond': 0}, 'gitHash': '8172acb', 'name': 'weaviate-1', 'shards': None, 'stats': {'objectCount': 0, 'shardCount': 0}, 'status': 'HEALTHY', 'version': '1.21.0'}
INFO:root:
INFO:root:{'batchStats': {'queueLength': 0, 'ratePerSecond': 0}, 'gitHash': '8172acb', 'name': 'weaviate-2', 'shards': None, 'stats': {'objectCount': 0, 'shardCount': 0}, 'status': 'HEALTHY', 'version': '1.21.0'}
INFO:root:
  1. Create a schema and import some objects.

This example requires a HuggingFace api token to create vectors.

export HUGGINGFACE_API_KEY=your-huggingface-api-key
python 01-create-schema-import-data.py

The first time running may produce the following error if the huggingface transformer model is not quite ready.

{'error': [{'message': 'update vector: failed with status: 503 error: Model sentence-transformers/msmarco-bert-base-dot-v5 is currently loading estimated time: 20'}]}

Sample output:

WEAVIATE_URL: https://weaviate-weaviate.apps.ocp.sandbox1234.openshift.com

WEAVIATE_URL: https://weaviate-weaviate.apps.ocp.sandbox1234.openshift.com is_ready() = True

Creating a class using the text2vec-huggingface vectorizer.
Question class already exists, skipping
importing question: 1
importing question: 2
...
  1. Perform a semantic search.
python 02-semantic-search.py
  1. Perform a retrieval augmented generative search.

This generative AI example requires an OpenAI API token.

export OPENAI_API_KEY=my_openai_api_key
python 03-generative-search.py
  1. Run the Gradio front end application example and visit the port reported with a web browser.
python 05-gradio
  1. Use the Weaviate Cloud Console to make GraphQL queries.
  • Add an Openshift route for your external cluster.
  • Navigate to the query editor and configure the header.
{
  "Authorization" : "Bearer my-weaviate-api-key",
  "X-HuggingFace-Api-Key" : "my-huggingface-api-key"
}
  • Enter the following sample GraphQL:
{
  Get {
    Question (
      nearText: {
        concepts: ["World history"]
      }
      limit: 2
    ) {
      question
      _additional {
        generate(
          singleResult: {
            prompt: """
              Convert the following into a question for twitter. Include emojis for fun, but do not include the answer: {question}.
            """
          }
        ) {
          singleResult
          error
        }
      }
    }
  }
}
  1. Delete the schema if necessary.
python 04-delete-schema.py