Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/typeagent/knowpro/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
from typing import cast, Literal, Protocol

from ..aitools.embeddings import NormalizedEmbedding
from ..storage.memory import propindex
from ..storage.memory.messageindex import IMessageTextEmbeddingIndex
from ..storage.memory.propindex import lookup_property_in_property_index, PropertyNames
from ..storage.memory.propindex import PropertyNames
from .collections import (
Match,
MatchAccumulator,
Expand Down Expand Up @@ -600,7 +601,7 @@ async def lookup_property(
property_value: str,
) -> list[ScoredSemanticRefOrdinal] | None:
if context.property_index is not None:
return await lookup_property_in_property_index(
return await propindex.lookup_property_in_property_index(
context.property_index,
property_name,
property_value,
Expand Down
4 changes: 2 additions & 2 deletions src/typeagent/knowpro/secindex.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

from ..storage.memory import propindex
from ..storage.memory.messageindex import build_message_index
from ..storage.memory.propindex import build_property_index
from ..storage.memory.reltermsindex import build_related_terms_index
from ..storage.memory.timestampindex import build_timestamp_index
from .convsettings import ConversationSettings, RelatedTermIndexSettings
Expand Down Expand Up @@ -66,5 +66,5 @@ async def build_transient_secondary_indexes[
await settings.get_storage_provider(),
settings.related_term_index_settings,
)
await build_property_index(conversation)
await propindex.build_property_index(conversation)
await build_timestamp_index(conversation)
6 changes: 3 additions & 3 deletions src/typeagent/storage/memory/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from datetime import datetime, timezone

from . import propindex
from ...knowpro.convsettings import MessageTextIndexSettings, RelatedTermIndexSettings
from ...knowpro.interfaces import (
ChunkFailure,
Expand All @@ -22,7 +23,6 @@
from .collections import MemoryMessageCollection, MemorySemanticRefCollection
from .convthreads import ConversationThreads
from .messageindex import MessageTextIndex
from .propindex import PropertyIndex
from .reltermsindex import RelatedTermsIndex
from .semrefindex import TermToSemanticRefIndex
from .timestampindex import TimestampToTextRangeIndex
Expand All @@ -35,7 +35,7 @@ class MemoryStorageProvider[TMessage: IMessage](IStorageProvider[TMessage]):
_semantic_ref_collection: MemorySemanticRefCollection

_conversation_index: TermToSemanticRefIndex
_property_index: PropertyIndex
_property_index: propindex.PropertyIndex
_timestamp_index: TimestampToTextRangeIndex
_message_text_index: MessageTextIndex
_related_terms_index: RelatedTermsIndex
Expand All @@ -58,7 +58,7 @@ def __init__(
self._semantic_ref_collection = MemorySemanticRefCollection()

self._conversation_index = TermToSemanticRefIndex()
self._property_index = PropertyIndex()
self._property_index = propindex.PropertyIndex()
self._timestamp_index = TimestampToTextRangeIndex()
self._related_terms_index = RelatedTermsIndex(related_terms_settings)
thread_settings = message_text_settings.embedding_index_settings
Expand Down
17 changes: 7 additions & 10 deletions src/typeagent/storage/sqlite/propindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

from ...knowpro import interfaces
from ...knowpro.interfaces import ScoredSemanticRefOrdinal
from ...storage.memory.propindex import (
make_property_term_text,
split_property_term_text,
)
from ...storage.memory import propindex


class SqlitePropertyIndex(interfaces.IPropertyToSemanticRefIndex):
Expand Down Expand Up @@ -51,9 +48,9 @@ async def add_property(
score = 1.0

# Normalize property name and value (to match in-memory implementation)
term_text = make_property_term_text(property_name, value)
term_text = propindex.make_property_term_text(property_name, value)
term_text = term_text.lower() # Matches PropertyIndex._prepare_term_text
property_name, value = split_property_term_text(term_text)
property_name, value = propindex.split_property_term_text(term_text)
# Remove "prop." prefix that was added by make_property_term_text
if property_name.startswith("prop."):
property_name = property_name[5:]
Expand Down Expand Up @@ -87,9 +84,9 @@ async def add_properties_batch(
else:
semref_id = ordinal
score = 1.0
term_text = make_property_term_text(property_name, value)
term_text = propindex.make_property_term_text(property_name, value)
term_text = term_text.lower()
property_name, value = split_property_term_text(term_text)
property_name, value = propindex.split_property_term_text(term_text)
if property_name.startswith("prop."):
property_name = property_name[5:]
rows.append((property_name, value, score, semref_id))
Expand All @@ -109,9 +106,9 @@ async def lookup_property(
value: str,
) -> list[interfaces.ScoredSemanticRefOrdinal] | None:
# Normalize property name and value (to match in-memory implementation)
term_text = make_property_term_text(property_name, value)
term_text = propindex.make_property_term_text(property_name, value)
term_text = term_text.lower() # Matches PropertyIndex._prepare_term_text
property_name, value = split_property_term_text(term_text)
property_name, value = propindex.split_property_term_text(term_text)
# Remove "prop." prefix that was added by make_property_term_text
if property_name.startswith("prop."):
property_name = property_name[5:]
Expand Down
Loading