Skip to content

Commit deb52ce

Browse files
authored
Update Moorcheh Vector Store (#19461)
1 parent ab31883 commit deb52ce

File tree

2 files changed

+21
-11
lines changed
  • llama-index-integrations/vector_stores/llama-index-vector-stores-moorcheh

2 files changed

+21
-11
lines changed

llama-index-integrations/vector_stores/llama-index-vector-stores-moorcheh/llama_index/vector_stores/moorcheh/base.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,33 +110,43 @@ def __init__(
110110
)
111111

112112
# Initialize Moorcheh client
113-
print("[DEBUG] Initializing MoorchehClient")
113+
logger.debug("Initializing MoorchehClient")
114114
self._client = MoorchehClient(api_key=self.api_key)
115115
self.is_embedding_query = False
116116
self._sparse_embedding_model = sparse_embedding_model
117+
self.namespace = namespace
117118

118-
print("[DEBUG] Listing namespaces...")
119+
logger.debug("Listing namespaces...")
119120
try:
120-
namespaces = self._client.list_namespaces()
121-
print(f"[DEBUG] Found namespaces: {namespaces}")
121+
namespaces_response = self._client.list_namespaces()
122+
namespaces = [
123+
namespace["namespace_name"]
124+
for namespace in namespaces_response.get("namespaces", [])
125+
]
126+
logger.debug("Found namespaces.")
122127
except Exception as e:
123-
print(f"[ERROR] Failed to list namespaces: {e}")
128+
logger.debug("Failed to list namespaces: {e}")
124129
raise
125130

126-
if self.namespace not in namespaces:
127-
print(f"[DEBUG] Namespace '{self.namespace}' not found. Creating...")
131+
# Check if the namespace exists
132+
if self.namespace in namespaces:
133+
logger.debug(
134+
"Namespace '{self.namespace}' already exists. No action required."
135+
)
136+
else:
137+
logger.debug("Namespace '{self.namespace}' not found. Creating it.")
138+
# If the namespace doesn't exist, create it
128139
try:
129140
self._client.create_namespace(
130141
namespace_name=self.namespace,
131142
type=self.namespace_type,
132143
vector_dimension=self.vector_dimension,
133144
)
145+
logger.debug("Namespace '{self.namespace}' created.")
134146
except Exception as e:
135-
print(f"[ERROR] Failed to create namespace: {e}")
147+
logger.debug("Failed to create namespace: {e}")
136148
raise
137149

138-
print("[DEBUG] MoorchehVectorStore initialization complete.")
139-
140150
# _client: MoorchehClient = PrivateAttr()
141151

142152
@property

llama-index-integrations/vector_stores/llama-index-vector-stores-moorcheh/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dev = [
2626

2727
[project]
2828
name = "llama-index-vector-stores-moorcheh"
29-
version = "0.1.0"
29+
version = "0.1.1"
3030
description = "llama-index vector_stores moorcheh integration"
3131
authors = [{name = "EdgeAI Innovations"}]
3232
requires-python = ">=3.10,<4.0"

0 commit comments

Comments
 (0)