Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit ·
f5e735b
1
Parent(s): 063d0a3
fix: resolve typescript build errors in internal portal navigation
Browse files
agents/nexus_checkpoint.py
CHANGED
|
@@ -41,7 +41,7 @@ class SQLAlchemySaver(BaseCheckpointSaver):
|
|
| 41 |
else:
|
| 42 |
stmt = select(NexusCheckpoint).where(
|
| 43 |
NexusCheckpoint.thread_id == str(thread_id)
|
| 44 |
-
).order_by(NexusCheckpoint.
|
| 45 |
|
| 46 |
result = await session.execute(stmt)
|
| 47 |
row = result.scalar_one_or_none()
|
|
@@ -56,7 +56,7 @@ class SQLAlchemySaver(BaseCheckpointSaver):
|
|
| 56 |
stmt = select(NexusCheckpoint)
|
| 57 |
if thread_id:
|
| 58 |
stmt = stmt.where(NexusCheckpoint.thread_id == str(thread_id))
|
| 59 |
-
stmt = stmt.order_by(NexusCheckpoint.
|
| 60 |
if limit:
|
| 61 |
stmt = stmt.limit(limit)
|
| 62 |
|
|
|
|
| 41 |
else:
|
| 42 |
stmt = select(NexusCheckpoint).where(
|
| 43 |
NexusCheckpoint.thread_id == str(thread_id)
|
| 44 |
+
).order_by(NexusCheckpoint.created_at.desc()).limit(1)
|
| 45 |
|
| 46 |
result = await session.execute(stmt)
|
| 47 |
row = result.scalar_one_or_none()
|
|
|
|
| 56 |
stmt = select(NexusCheckpoint)
|
| 57 |
if thread_id:
|
| 58 |
stmt = stmt.where(NexusCheckpoint.thread_id == str(thread_id))
|
| 59 |
+
stmt = stmt.order_by(NexusCheckpoint.created_at.desc())
|
| 60 |
if limit:
|
| 61 |
stmt = stmt.limit(limit)
|
| 62 |
|
agents/nexus_master.py
CHANGED
|
@@ -492,7 +492,6 @@ async def nexus_tool_executor(state: NexusState) -> Dict[str, Any]:
|
|
| 492 |
task_calls.append((call_id, get_ticket_details_tool(params.get("ticket_id"), ws_id, role=role)))
|
| 493 |
elif tool_name == "SUMMARIZE_WORKSPACE":
|
| 494 |
task_calls.append((call_id, summarize_workspace_tool(ws_id, role=role)))
|
| 495 |
-
direct_pass = True
|
| 496 |
elif tool_name == "MEMORY_RECALL":
|
| 497 |
task_calls.append((call_id, nexus_interaction_recall_tool(params.get("query", query), ws_id, state["user_id"])))
|
| 498 |
elif tool_name == "GET_ANALYTICS":
|
|
@@ -529,7 +528,7 @@ async def nexus_tool_executor(state: NexusState) -> Dict[str, Any]:
|
|
| 529 |
"messages": tool_messages,
|
| 530 |
"pending_actions": [] if is_approved else pending_actions,
|
| 531 |
"action_approved": is_approved,
|
| 532 |
-
"current_tool_output":
|
| 533 |
}
|
| 534 |
|
| 535 |
from langgraph.errors import GraphInterrupt
|
|
@@ -553,16 +552,10 @@ class ResponderOutput(BaseModel):
|
|
| 553 |
async def nexus_responder(state: NexusState) -> Dict[str, Any]:
|
| 554 |
"""
|
| 555 |
Formats the final response based on role and tool output.
|
| 556 |
-
|
| 557 |
"""
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
last_tool_msg = [m for m in state["messages"] if isinstance(m, ToolMessage)][-1]
|
| 561 |
-
msg = AIMessage(content=last_tool_msg.content)
|
| 562 |
-
msg.id = str(uuid4())
|
| 563 |
-
return {"messages": [msg], "confidence_score": 1.0}
|
| 564 |
-
|
| 565 |
-
llm = get_llm().with_structured_output(ResponderOutput)
|
| 566 |
sources = ", ".join(state.get("sources", []))
|
| 567 |
|
| 568 |
# Human-readable mapping for UI/Persona consistency
|
|
|
|
| 492 |
task_calls.append((call_id, get_ticket_details_tool(params.get("ticket_id"), ws_id, role=role)))
|
| 493 |
elif tool_name == "SUMMARIZE_WORKSPACE":
|
| 494 |
task_calls.append((call_id, summarize_workspace_tool(ws_id, role=role)))
|
|
|
|
| 495 |
elif tool_name == "MEMORY_RECALL":
|
| 496 |
task_calls.append((call_id, nexus_interaction_recall_tool(params.get("query", query), ws_id, state["user_id"])))
|
| 497 |
elif tool_name == "GET_ANALYTICS":
|
|
|
|
| 528 |
"messages": tool_messages,
|
| 529 |
"pending_actions": [] if is_approved else pending_actions,
|
| 530 |
"action_approved": is_approved,
|
| 531 |
+
"current_tool_output": state.get("current_tool_output")
|
| 532 |
}
|
| 533 |
|
| 534 |
from langgraph.errors import GraphInterrupt
|
|
|
|
| 552 |
async def nexus_responder(state: NexusState) -> Dict[str, Any]:
|
| 553 |
"""
|
| 554 |
Formats the final response based on role and tool output.
|
| 555 |
+
Uses high-intelligence LLM to incorporate visualizations (Mermaid).
|
| 556 |
"""
|
| 557 |
+
|
| 558 |
+
llm = get_llm()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 559 |
sources = ", ".join(state.get("sources", []))
|
| 560 |
|
| 561 |
# Human-readable mapping for UI/Persona consistency
|
alembic/versions/d4e1f2a3b4c5_add_timestamps_to_nexus_checkpoints.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""add timestamps to nexus checkpoints
|
| 2 |
+
|
| 3 |
+
Revision ID: d4e1f2a3b4c5
|
| 4 |
+
Revises: be2b715c4717
|
| 5 |
+
Create Date: 2026-04-22 13:58:00.000000
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from alembic import op
|
| 9 |
+
import sqlalchemy as sa
|
| 10 |
+
from sqlalchemy.sql import func
|
| 11 |
+
|
| 12 |
+
# revision identifiers, used by Alembic.
|
| 13 |
+
revision = 'd4e1f2a3b4c5'
|
| 14 |
+
down_revision = 'be2b715c4717'
|
| 15 |
+
branch_labels = None
|
| 16 |
+
depends_on = None
|
| 17 |
+
|
| 18 |
+
def upgrade():
|
| 19 |
+
# Add created_at to nexus_checkpoints
|
| 20 |
+
op.add_column('nexus_checkpoints', sa.Column('created_at', sa.DateTime(), server_default=func.now(), nullable=True))
|
| 21 |
+
# Add created_at to nexus_checkpoint_writes
|
| 22 |
+
op.add_column('nexus_checkpoint_writes', sa.Column('created_at', sa.DateTime(), server_default=func.now(), nullable=True))
|
| 23 |
+
|
| 24 |
+
def downgrade():
|
| 25 |
+
op.drop_column('nexus_checkpoint_writes', 'created_at')
|
| 26 |
+
op.drop_column('nexus_checkpoints', 'created_at')
|
models/nexus_checkpoint.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from sqlalchemy import Column, String, LargeBinary, Integer
|
| 2 |
from core.database import Base
|
| 3 |
|
| 4 |
class NexusCheckpoint(Base):
|
|
@@ -17,6 +17,8 @@ class NexusCheckpoint(Base):
|
|
| 17 |
checkpoint_data = Column(LargeBinary, nullable=False)
|
| 18 |
metadata_data = Column(LargeBinary, nullable=True)
|
| 19 |
|
|
|
|
|
|
|
| 20 |
class NexusCheckpointWrite(Base):
|
| 21 |
"""
|
| 22 |
Stores intermediate task writes for LangGraph async execution.
|
|
@@ -30,3 +32,5 @@ class NexusCheckpointWrite(Base):
|
|
| 30 |
|
| 31 |
channel = Column(String, nullable=False)
|
| 32 |
value = Column(LargeBinary, nullable=False)
|
|
|
|
|
|
|
|
|
| 1 |
+
from sqlalchemy import Column, String, LargeBinary, Integer, DateTime, func
|
| 2 |
from core.database import Base
|
| 3 |
|
| 4 |
class NexusCheckpoint(Base):
|
|
|
|
| 17 |
checkpoint_data = Column(LargeBinary, nullable=False)
|
| 18 |
metadata_data = Column(LargeBinary, nullable=True)
|
| 19 |
|
| 20 |
+
created_at = Column(DateTime, server_default=func.now())
|
| 21 |
+
|
| 22 |
class NexusCheckpointWrite(Base):
|
| 23 |
"""
|
| 24 |
Stores intermediate task writes for LangGraph async execution.
|
|
|
|
| 32 |
|
| 33 |
channel = Column(String, nullable=False)
|
| 34 |
value = Column(LargeBinary, nullable=False)
|
| 35 |
+
|
| 36 |
+
created_at = Column(DateTime, server_default=func.now())
|