Skip to content

Commit 301a6ac

Browse files
committed
examples: use objectbox API #56
1 parent fec7b3d commit 301a6ac

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

example/ollama/main.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
# using objectbox as a vector store
33

44
import ollama
5-
import objectbox
6-
from objectbox.model import *
7-
from objectbox.model.properties import *
5+
from objectbox import *
86

97
documents = [
108
"Llamas are members of the camelid family meaning they're pretty closely related to vicuñas and camels",
@@ -16,7 +14,7 @@
1614
]
1715

1816
# Have fresh data for each start
19-
objectbox.Store.remove_db_files("objectbox")
17+
Store.remove_db_files("objectbox")
2018

2119
@Entity()
2220
class DocumentEmbedding:
@@ -27,7 +25,7 @@ class DocumentEmbedding:
2725
distance_type=VectorDistanceType.COSINE
2826
))
2927

30-
store = objectbox.Store()
28+
store = Store()
3129
box = store.box(DocumentEmbedding)
3230

3331
print("Documents to embed: ", len(documents))

example/tasks/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from cmd import Cmd
2-
import objectbox
3-
from objectbox.model import *
2+
from objectbox import *
43
import time
54

65
@Entity()
@@ -24,7 +23,7 @@ def format_date(timestamp_ms: int) -> str:
2423

2524
class TasklistCmd(Cmd):
2625
prompt = "> "
27-
_store = objectbox.Store(directory="tasklist-db")
26+
_store = Store(directory="tasklist-db")
2827
_box = _store.box(Task)
2928

3029
def do_ls(self, _):

example/vectorsearch-cities/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from cmd import Cmd
2-
import objectbox
3-
from objectbox.model import *
2+
from objectbox import *
43
import time
54
import csv
65
import os
@@ -32,7 +31,7 @@ def __init__(self, *args):
3231
Cmd.__init__(self, *args)
3332
dbdir = "cities-db"
3433
new_db = not os.path.exists(dbdir)
35-
self._store = objectbox.Store(directory=dbdir)
34+
self._store = Store(directory=dbdir)
3635
self._box = self._store.box(City)
3736
if new_db:
3837
with open(os.path.join(os.path.dirname(__file__), 'cities.csv')) as f:

0 commit comments

Comments
 (0)