mirror of
https://github.com/mruwnik/memory.git
synced 2025-07-30 06:36:07 +02:00
fix approx tokens call
This commit is contained in:
parent
86c96da1b9
commit
907375eee5
@ -180,6 +180,7 @@ async def observe(
|
|||||||
session_id: UUID to group observations from same conversation
|
session_id: UUID to group observations from same conversation
|
||||||
agent_model: AI model making observations (for quality tracking)
|
agent_model: AI model making observations (for quality tracking)
|
||||||
"""
|
"""
|
||||||
|
logger.info("MCP: Observing")
|
||||||
tasks = [
|
tasks = [
|
||||||
(
|
(
|
||||||
observation,
|
observation,
|
||||||
@ -237,6 +238,7 @@ async def search_observations(
|
|||||||
Returns: List with content, tags, created_at, metadata
|
Returns: List with content, tags, created_at, metadata
|
||||||
Results sorted by relevance to your query.
|
Results sorted by relevance to your query.
|
||||||
"""
|
"""
|
||||||
|
logger.info("MCP: Searching observations for %s", query)
|
||||||
semantic_text = observation.generate_semantic_text(
|
semantic_text = observation.generate_semantic_text(
|
||||||
subject=subject or "",
|
subject=subject or "",
|
||||||
observation_type="".join(observation_types or []),
|
observation_type="".join(observation_types or []),
|
||||||
@ -297,6 +299,7 @@ async def create_note(
|
|||||||
confidences: Dict of scores (0.0-1.0), e.g. {"observation_accuracy": 0.9}
|
confidences: Dict of scores (0.0-1.0), e.g. {"observation_accuracy": 0.9}
|
||||||
tags: Organization tags for filtering and discovery
|
tags: Organization tags for filtering and discovery
|
||||||
"""
|
"""
|
||||||
|
logger.info("MCP: creating note: %s", subject)
|
||||||
if filename:
|
if filename:
|
||||||
path = pathlib.Path(filename)
|
path = pathlib.Path(filename)
|
||||||
if not path.is_absolute():
|
if not path.is_absolute():
|
||||||
|
@ -108,10 +108,3 @@ async def get_authenticated_user() -> dict:
|
|||||||
"client_id": access_token.client_id,
|
"client_id": access_token.client_id,
|
||||||
"user": user_info,
|
"user": user_info,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@mcp.tool()
|
|
||||||
async def send_response(response: str) -> dict:
|
|
||||||
"""Send a response to the user."""
|
|
||||||
logger.info(f"Sending response: {response}")
|
|
||||||
return {"response": response}
|
|
||||||
|
@ -28,7 +28,7 @@ from sqlalchemy.dialects.postgresql import BYTEA
|
|||||||
from sqlalchemy.orm import Session, relationship
|
from sqlalchemy.orm import Session, relationship
|
||||||
from sqlalchemy.types import Numeric
|
from sqlalchemy.types import Numeric
|
||||||
|
|
||||||
from memory.common import settings
|
from memory.common import settings, tokens
|
||||||
import memory.common.extract as extract
|
import memory.common.extract as extract
|
||||||
import memory.common.collections as collections
|
import memory.common.collections as collections
|
||||||
import memory.common.chunker as chunker
|
import memory.common.chunker as chunker
|
||||||
@ -125,8 +125,7 @@ def chunk_mixed(content: str, image_paths: Sequence[str]) -> list[extract.DataCh
|
|||||||
)
|
)
|
||||||
|
|
||||||
chunks: list[extract.DataChunk] = [full_text]
|
chunks: list[extract.DataChunk] = [full_text]
|
||||||
tokens = chunker.approx_token_count(content)
|
if tokens.approx_token_count(content) > chunker.DEFAULT_CHUNK_TOKENS * 2:
|
||||||
if tokens > chunker.DEFAULT_CHUNK_TOKENS * 2:
|
|
||||||
chunks += [
|
chunks += [
|
||||||
extract.DataChunk(data=add_pics(c, images), metadata={"tags": tags})
|
extract.DataChunk(data=add_pics(c, images), metadata={"tags": tags})
|
||||||
for c in chunker.chunk_text(content)
|
for c in chunker.chunk_text(content)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user