Skip to content

Commit 1a31bd5

Browse files
dan-obxgreenrobot
authored andcommitted
example/ollama: updated to llama3 and improved objectbox API #43
1 parent 494e81b commit 1a31bd5

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

example/ollama/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ based on https://ollama.com/blog/embedding-models
88

99
2. Pull models
1010

11-
ollama pull ollama2
11+
ollama pull llama3
1212
ollama pull mxbai-embed-large
1313

1414
3. Change to example directory:

example/ollama/llamas.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
from objectbox.model.properties import *
1919
import numpy as np
2020

21-
obx_remove_db_files(c_str("objectbox")) # Have fresh data for each start
21+
# Have fresh data for each start
22+
objectbox.Store.remove_db_files("objectbox")
2223

2324
@Entity(id=1, uid=1)
2425
class DocumentEmbedding:
@@ -27,16 +28,16 @@ class DocumentEmbedding:
2728
embedding = Property(np.ndarray, type=PropertyType.floatVector, id=3, uid=1003, index=HnswIndex(
2829
id=3, uid=10001,
2930
dimensions=1024,
30-
distance_type=HnswDistanceType.COSINE
31+
distance_type=VectorDistanceType.COSINE
3132
))
3233

3334
model = Model()
3435
model.entity(DocumentEmbedding, last_property_id=IdUid(3, 1003))
3536
model.last_entity_id = IdUid(1, 1)
3637
model.last_index_id = IdUid(3,10001)
3738

38-
ob = objectbox.Builder().model(model).build()
39-
box = objectbox.Box(ob, DocumentEmbedding)
39+
store = objectbox.Store(model=model)
40+
box = store.box(DocumentEmbedding)
4041

4142
print("Documents to embed: ", len(documents))
4243

@@ -72,7 +73,7 @@ class DocumentEmbedding:
7273

7374
# generate a response combining the prompt and data we retrieved in step 2
7475
output = ollama.generate(
75-
model="llama2",
76+
model="llama3",
7677
prompt=f"Using this data: {data}. Respond to this prompt: {prompt}"
7778
)
7879

0 commit comments

Comments
 (0)