Skip to content

Commit

Permalink
Add support for multi2vec-cohere module
Browse files Browse the repository at this point in the history
  • Loading branch information
antas-marcin committed Nov 8, 2024
1 parent b8bbefc commit 7743715
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
8 changes: 7 additions & 1 deletion weaviate/templates/apiKeyCohereSecret.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{{- $t2vCohere := and (index .Values "modules" "text2vec-cohere" "enabled") (index .Values "modules" "text2vec-cohere" "apiKey") -}}
{{- $generativeCohere := and (index .Values "modules" "generative-cohere" "enabled") (index .Values "modules" "generative-cohere" "apiKey") }}
{{- $rerankerCohere := and (index .Values "modules" "reranker-cohere" "enabled") (index .Values "modules" "reranker-cohere" "apiKey") }}
{{- $cohere := or ($t2vCohere) ($generativeCohere) ($rerankerCohere) }}
{{- $multi2vecCohere := and (index .Values "modules" "multi2vec-cohere" "enabled") (index .Values "modules" "multi2vec-cohere" "apiKey") }}
{{- $cohere := or ($t2vCohere) ($generativeCohere) ($rerankerCohere) ($multi2vecCohere) }}
{{- if $cohere }}

{{- $apiKeys := list }}
Expand All @@ -14,6 +15,9 @@
{{- if $rerankerCohere }}
{{- $apiKeys = append $apiKeys (index .Values "modules" "reranker-cohere" "apiKey") -}}
{{- end }}
{{- if $multi2vecCohere }}
{{- $apiKeys = append $apiKeys (index .Values "modules" "multi2vec-cohere" "apiKey") -}}
{{- end }}

{{- if gt (len ($apiKeys | uniq)) 1 -}}
{{- fail "Cohere modules activated, but their keys differ. Use the same key on all activated Cohere modules." }}
Expand All @@ -32,6 +36,8 @@ data:
apiKey: {{ index .Values "modules" "generative-cohere" "apiKey" | b64enc }}
{{- else if (index .Values "modules" "reranker-cohere" "apiKey") }}
apiKey: {{ index .Values "modules" "reranker-cohere" "apiKey" | b64enc }}
{{- else if (index .Values "modules" "multi2vec-cohere" "apiKey") }}
apiKey: {{ index .Values "modules" "multi2vec-cohere" "apiKey" | b64enc }}
{{- else }}
apiKey: {{ index .Values "modules" "text2vec-cohere" "apiKey" | b64enc }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion weaviate/templates/weaviateStatefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ spec:
name: weaviate-huggingface
key: apiKey
{{- end }}
{{- if or (and (index .Values "modules" "text2vec-cohere" "enabled") (index .Values "modules" "text2vec-cohere" "apiKey")) (and (index .Values "modules" "generative-cohere" "enabled") (index .Values "modules" "generative-cohere" "apiKey")) (and (index .Values "modules" "reranker-cohere" "enabled") (index .Values "modules" "reranker-cohere" "apiKey")) }}
{{- if or (and (index .Values "modules" "text2vec-cohere" "enabled") (index .Values "modules" "text2vec-cohere" "apiKey")) (and (index .Values "modules" "generative-cohere" "enabled") (index .Values "modules" "generative-cohere" "apiKey")) (and (index .Values "modules" "reranker-cohere" "enabled") (index .Values "modules" "reranker-cohere" "apiKey")) (and (index .Values "modules" "multi2vec-cohere" "enabled") (index .Values "modules" "multi2vec-cohere" "apiKey")) }}
- name: COHERE_APIKEY
valueFrom:
secretKeyRef:
Expand Down
12 changes: 12 additions & 0 deletions weaviate/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,18 @@ modules:
# an environment variable
apiKey: ''

# The multi2vec-cohere module uses Cohere API
# to dynamically compute vector embeddings.
# More information about Cohere API can be found here: https://docs.cohere.ai/
multi2vec-cohere:

# enable if you want to use Cohere module
enabled: false

# Set your Cohere API Key to be passed to Weaviate pod as
# an environment variable
apiKey: ''

# The qna-transformers module uses neural networks, such as BERT,
# DistilBERT, to find an answer in text to a given question
qna-transformers:
Expand Down

0 comments on commit 7743715

Please sign in to comment.