Skip to content
Merged
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
16 changes: 14 additions & 2 deletions openviking/utils/embedding_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from typing import Dict, Optional

from openviking.core.context import Context, ContextLevel, ResourceContentType, Vectorize
from openviking.core.directories import get_context_type_for_uri
from openviking.server.identity import RequestContext
from openviking.storage.queuefs import get_queue_manager
from openviking.storage.queuefs.embedding_msg_converter import EmbeddingMsgConverter
Expand Down Expand Up @@ -326,8 +327,13 @@ async def index_resource(

1. Reads .abstract.md and .overview.md and vectorizes them.
2. Scans files in the directory and vectorizes them.

The context_type is derived from the URI so that memory directories
(``/memories/``) are indexed as ``"memory"`` rather than the default
``"resource"``.
"""
viking_fs = get_viking_fs()
context_type = get_context_type_for_uri(uri)

# 1. Index Directory Metadata
abstract_uri = f"{uri}/.abstract.md"
Expand All @@ -347,7 +353,9 @@ async def index_resource(
overview = content.decode("utf-8")

if abstract or overview:
await vectorize_directory_meta(uri, abstract, overview, ctx=ctx)
await vectorize_directory_meta(
uri, abstract, overview, context_type=context_type, ctx=ctx
)

# 2. Index Files
try:
Expand All @@ -368,7 +376,11 @@ async def index_resource(
# For direct indexing, we might not have summaries.
# We pass empty summary_dict, vectorize_file will try to read content for text files.
await vectorize_file(
file_path=file_uri, summary_dict={"name": file_name}, parent_uri=uri, ctx=ctx
file_path=file_uri,
summary_dict={"name": file_name},
parent_uri=uri,
context_type=context_type,
ctx=ctx,
)

except Exception as e:
Expand Down
Loading