MCPcopy
hub / github.com/NevaMind-AI/memU / _create_resource_with_caption

Method _create_resource_with_caption

src/memu/app/memorize.py:352–385  ·  view source on GitHub ↗
(
        self,
        *,
        resource_url: str,
        modality: str,
        local_path: str,
        caption: str | None,
        store: Database,
        embed_client: Any | None = None,
        user: Mapping[str, Any] | None = None,
    )

Source from the content-addressed store, hash-verified

350 return local_path, preprocessed_resources
351
352 async def _create_resource_with_caption(
353 self,
354 *,
355 resource_url: str,
356 modality: str,
357 local_path: str,
358 caption: str | None,
359 store: Database,
360 embed_client: Any | None = None,
361 user: Mapping[str, Any] | None = None,
362 ) -> Resource:
363 caption_text = caption.strip() if caption else None
364 if caption_text:
365 client = embed_client or self._get_llm_client()
366 caption_embedding = (await client.embed([caption_text]))[0]
367 else:
368 caption_embedding = None
369
370 res = store.resource_repo.create_resource(
371 url=resource_url,
372 modality=modality,
373 local_path=local_path,
374 caption=caption_text,
375 embedding=caption_embedding,
376 user_data=dict(user or {}),
377 )
378 # if caption:
379 # caption_text = caption.strip()
380 # if caption_text:
381 # res.caption = caption_text
382 # client = embed_client or self._get_llm_client()
383 # res.embedding = (await client.embed([caption_text]))[0]
384 # res.updated_at = pendulum.now()
385 return res
386
387 def _resolve_memory_types(self) -> list[MemoryType]:
388 configured_types = self.memorize_config.memory_types or DEFAULT_MEMORY_TYPES

Callers 1

Calls 3

_get_llm_clientMethod · 0.80
embedMethod · 0.45
create_resourceMethod · 0.45

Tested by

no test coverage detected