Skip to content

Commit df4d36b

Browse files
Allow using Ollama as a vectorizer
1 parent fa93d2d commit df4d36b

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

README.md

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ client.schema.create(
6363
"name": "category"
6464
}
6565
],
66-
# Possible values: 'text2vec-cohere', 'text2vec-openai', 'text2vec-huggingface', 'text2vec-transformers', 'text2vec-contextionary', 'img2vec-neural', 'multi2vec-clip', 'ref2vec-centroid'
66+
# Possible values: 'text2vec-cohere', 'text2vec-ollama', 'text2vec-openai', 'text2vec-huggingface', 'text2vec-transformers', 'text2vec-contextionary', 'img2vec-neural', 'multi2vec-clip', 'ref2vec-centroid'
6767
vectorizer: "text2vec-openai"
6868
)
6969

@@ -73,9 +73,6 @@ client.schema.get(class_name: 'Question')
7373
# Get the schema
7474
client.schema.list()
7575

76-
# Remove a class (and all data in the instances) from the schema.
77-
client.schema.delete(class_name: 'Question')
78-
7976
# Update settings of an existing schema class.
8077
# Does not support modifying existing properties.
8178
client.schema.update(
@@ -94,6 +91,52 @@ client.schema.add_property(
9491

9592
# Inspect the shards of a class
9693
client.schema.shards(class_name: 'Question')
94+
95+
# Remove a class (and all data in the instances) from the schema.
96+
client.schema.delete(class_name: 'Question')
97+
98+
# Creating a new data object class in the schema while configuring the vectorizer on the schema and on individual properties (Ollama example)
99+
client.schema.create(
100+
class_name: 'Question',
101+
description: 'Information from a Jeopardy! question',
102+
properties: [
103+
{
104+
"dataType": ["text"],
105+
"description": "The question",
106+
"name": "question"
107+
# By default all properties are included in the vector
108+
}, {
109+
"dataType": ["text"],
110+
"description": "The answer",
111+
"name": "answer",
112+
"moduleConfig": {
113+
"text2vec-ollama": {
114+
"skip": false,
115+
"vectorizePropertyName": true,
116+
},
117+
},
118+
}, {
119+
"dataType": ["text"],
120+
"description": "The category",
121+
"name": "category",
122+
"indexFilterable": true,
123+
"indexSearchable": false,
124+
"moduleConfig": {
125+
"text2vec-ollama": {
126+
"skip": true, # Don't include in the vector
127+
},
128+
},
129+
}
130+
],
131+
# Possible values: 'text2vec-cohere', 'text2vec-ollama', 'text2vec-openai', 'text2vec-huggingface', 'text2vec-transformers', 'text2vec-contextionary', 'img2vec-neural', 'multi2vec-clip', 'ref2vec-centroid'
132+
vectorizer: "text2vec-ollama",
133+
module_config: {
134+
"text2vec-ollama": {
135+
apiEndpoint: "http://localhost:11434",
136+
model: "mxbai-embed-large",
137+
},
138+
},
139+
)
97140
```
98141

99142
### Using the Objects endpoint

lib/weaviate/client.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Client
1010
API_VERSION = "v1"
1111

1212
API_KEY_HEADERS = {
13+
ollama: "X-Ollama-Not-Used",
1314
openai: "X-OpenAI-Api-Key",
1415
azure_openai: "X-Azure-Api-Key",
1516
cohere: "X-Cohere-Api-Key",

0 commit comments

Comments
 (0)