mirror of
https://github.com/mruwnik/memory.git
synced 2025-06-28 23:24:43 +02:00
use LW in search
This commit is contained in:
parent
1538d38bf6
commit
f0d441ffe9
@ -6,18 +6,23 @@ import asyncio
|
|||||||
import logging
|
import logging
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from memory.api.search.embeddings import search_embeddings
|
from memory.common import extract, settings
|
||||||
from memory.api.search.bm25 import search_bm25
|
|
||||||
from memory.api.search.utils import SearchFilters, SearchResult
|
|
||||||
|
|
||||||
from memory.api.search.utils import group_chunks, with_timeout
|
|
||||||
from memory.common import extract
|
|
||||||
from memory.common.collections import (
|
from memory.common.collections import (
|
||||||
ALL_COLLECTIONS,
|
ALL_COLLECTIONS,
|
||||||
MULTIMODAL_COLLECTIONS,
|
MULTIMODAL_COLLECTIONS,
|
||||||
TEXT_COLLECTIONS,
|
TEXT_COLLECTIONS,
|
||||||
)
|
)
|
||||||
from memory.common import settings
|
from memory.api.search.embeddings import search_embeddings
|
||||||
|
|
||||||
|
if settings.ENABLE_BM25_SEARCH:
|
||||||
|
from memory.api.search.bm25 import search_bm25
|
||||||
|
|
||||||
|
from memory.api.search.utils import (
|
||||||
|
SearchFilters,
|
||||||
|
SearchResult,
|
||||||
|
group_chunks,
|
||||||
|
with_timeout,
|
||||||
|
)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ from sqlalchemy import (
|
|||||||
Text,
|
Text,
|
||||||
func,
|
func,
|
||||||
)
|
)
|
||||||
from sqlalchemy.dialects.postgresql import JSONB, TSVECTOR, UUID
|
from sqlalchemy.dialects.postgresql import JSONB, TSVECTOR
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
from memory.common import settings
|
from memory.common import settings
|
||||||
@ -31,7 +31,6 @@ import memory.common.formatters.observation as observation
|
|||||||
|
|
||||||
from memory.common.db.models.source_item import (
|
from memory.common.db.models.source_item import (
|
||||||
SourceItem,
|
SourceItem,
|
||||||
Chunk,
|
|
||||||
SourceItemPayload,
|
SourceItemPayload,
|
||||||
clean_filename,
|
clean_filename,
|
||||||
chunk_mixed,
|
chunk_mixed,
|
||||||
@ -576,6 +575,11 @@ class ForumPost(SourceItem):
|
|||||||
def _chunk_contents(self) -> Sequence[extract.DataChunk]:
|
def _chunk_contents(self) -> Sequence[extract.DataChunk]:
|
||||||
return chunk_mixed(cast(str, self.content), cast(list[str], self.images))
|
return chunk_mixed(cast(str, self.content), cast(list[str], self.images))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_collections(cls) -> list[str]:
|
||||||
|
# Very sad that I didn't keep the names consistent... Qdrant doesn't allow renaming collections
|
||||||
|
return ["forum"]
|
||||||
|
|
||||||
|
|
||||||
class MiscDoc(SourceItem):
|
class MiscDoc(SourceItem):
|
||||||
__tablename__ = "misc_doc"
|
__tablename__ = "misc_doc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user