updated versions fixed issues
This commit is contained in:
parent
a8a676f860
commit
f929165a89
4 changed files with 21 additions and 14 deletions
|
@ -1,4 +1,4 @@
|
|||
FROM python:3.11-slim
|
||||
FROM python:3.13-slim
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
@ -7,6 +7,7 @@ WORKDIR /app
|
|||
RUN apt-get update && apt-get install -y \
|
||||
gcc \
|
||||
g++ \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy requirements and install Python dependencies
|
||||
|
|
|
@ -206,8 +206,8 @@ async def chat_with_memory(request: ChatRequest):
|
|||
result = await mem0_manager.chat_with_memory(
|
||||
message=request.message,
|
||||
user_id=request.user_id,
|
||||
context=request.context,
|
||||
metadata=request.metadata
|
||||
agent_id=request.agent_id,
|
||||
run_id=request.run_id,
|
||||
)
|
||||
|
||||
return result
|
||||
|
@ -249,7 +249,7 @@ async def search_memories(request: MemorySearchRequest):
|
|||
query=request.query,
|
||||
user_id=request.user_id,
|
||||
limit=request.limit,
|
||||
threshold=request.threshold,
|
||||
threshold=request.threshold or 0.2,
|
||||
filters=request.filters,
|
||||
agent_id=request.agent_id,
|
||||
run_id=request.run_id
|
||||
|
@ -341,9 +341,8 @@ async def get_graph_relationships(user_id: str):
|
|||
"""Get graph relationships - pure Mem0 passthrough."""
|
||||
try:
|
||||
logger.info(f"Retrieving graph relationships for user: {user_id}")
|
||||
|
||||
result = await mem0_manager.get_graph_relationships(user_id=user_id)
|
||||
|
||||
result = await mem0_manager.get_graph_relationships(user_id=user_id, agent_id=None, run_id=None)
|
||||
|
||||
return result
|
||||
|
||||
except Exception as e:
|
||||
|
@ -417,14 +416,14 @@ async def get_user_stats(user_id: str):
|
|||
|
||||
# Get actual memory count for this user
|
||||
try:
|
||||
user_memories = await mem0_manager.get_user_memories(user_id=user_id, limit=1000)
|
||||
user_memories = await mem0_manager.get_user_memories(user_id=user_id, limit=10000)
|
||||
memory_count = len(user_memories)
|
||||
except:
|
||||
memory_count = 0
|
||||
|
||||
# Get relationship count for this user
|
||||
try:
|
||||
graph_data = await mem0_manager.get_graph_relationships(user_id=user_id)
|
||||
graph_data = await mem0_manager.get_graph_relationships(user_id=user_id, agent_id=None, run_id=None)
|
||||
relationship_count = len(graph_data.get('relationships', []))
|
||||
except:
|
||||
relationship_count = 0
|
||||
|
@ -467,6 +466,7 @@ async def get_active_users():
|
|||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
print("Starting UVicorn server...")
|
||||
uvicorn.run(
|
||||
"main:app",
|
||||
host="0.0.0.0",
|
||||
|
|
|
@ -73,7 +73,7 @@ class Mem0Manager:
|
|||
async def add_memories(
|
||||
self,
|
||||
messages: List[Dict[str, str]],
|
||||
user_id: str = "default",
|
||||
user_id: Optional[str] = "default",
|
||||
agent_id: Optional[str] = None,
|
||||
run_id: Optional[str] = None,
|
||||
metadata: Optional[Dict[str, Any]] = None
|
||||
|
@ -107,7 +107,7 @@ class Mem0Manager:
|
|||
async def search_memories(
|
||||
self,
|
||||
query: str,
|
||||
user_id: str = "default",
|
||||
user_id: Optional[str] = "default",
|
||||
limit: int = 5,
|
||||
threshold: Optional[float] = None,
|
||||
filters: Optional[Dict[str, Any]] = None,
|
||||
|
|
|
@ -14,7 +14,9 @@ class ChatMessage(BaseModel):
|
|||
class ChatRequest(BaseModel):
|
||||
"""Ultra-minimal chat request."""
|
||||
message: str = Field(..., description="User message")
|
||||
user_id: str = Field("default", description="User identifier")
|
||||
user_id: Optional[str] = Field("default", description="User identifier")
|
||||
agent_id: Optional[str] = Field(None, description="Agent identifier")
|
||||
run_id: Optional[str] = Field(None, description="Run identifier")
|
||||
context: Optional[List[ChatMessage]] = Field(None, description="Previous conversation context")
|
||||
metadata: Optional[Dict[str, Any]] = Field(None, description="Additional metadata")
|
||||
|
||||
|
@ -22,7 +24,7 @@ class ChatRequest(BaseModel):
|
|||
class MemoryAddRequest(BaseModel):
|
||||
"""Request to add memories with hierarchy support - open-source compatible."""
|
||||
messages: List[ChatMessage] = Field(..., description="Messages to process")
|
||||
user_id: str = Field("default", description="User identifier")
|
||||
user_id: Optional[str] = Field("default", description="User identifier")
|
||||
agent_id: Optional[str] = Field(None, description="Agent identifier")
|
||||
run_id: Optional[str] = Field(None, description="Run identifier")
|
||||
metadata: Optional[Dict[str, Any]] = Field(None, description="Additional metadata")
|
||||
|
@ -31,7 +33,9 @@ class MemoryAddRequest(BaseModel):
|
|||
class MemorySearchRequest(BaseModel):
|
||||
"""Request to search memories with hierarchy filtering."""
|
||||
query: str = Field(..., description="Search query")
|
||||
user_id: str = Field("default", description="User identifier")
|
||||
user_id: Optional[str] = Field("default", description="User identifier")
|
||||
agent_id: Optional[str] = Field(None, description="Agent identifier")
|
||||
run_id: Optional[str] = Field(None, description="Run identifier")
|
||||
limit: int = Field(5, description="Maximum number of results")
|
||||
threshold: Optional[float] = Field(None, description="Minimum relevance score")
|
||||
filters: Optional[Dict[str, Any]] = Field(None, description="Additional filters")
|
||||
|
@ -56,6 +60,8 @@ class MemoryItem(BaseModel):
|
|||
id: str = Field(..., description="Memory unique identifier")
|
||||
memory: str = Field(..., description="Memory content")
|
||||
user_id: Optional[str] = Field(None, description="Associated user ID")
|
||||
agent_id: Optional[str] = Field(None, description="Associated agent ID")
|
||||
run_id: Optional[str] = Field(None, description="Associated run ID")
|
||||
metadata: Optional[Dict[str, Any]] = Field(None, description="Memory metadata")
|
||||
score: Optional[float] = Field(None, description="Relevance score (for search results)")
|
||||
created_at: Optional[str] = Field(None, description="Creation timestamp")
|
||||
|
|
Loading…
Reference in a new issue