Spaces:
Sleeping
Sleeping
yc1838 commited on
Commit ·
abd5331
1
Parent(s): 22d6053
lint
Browse files- src/lilith_agent/app.py +1 -1
- src/lilith_agent/memory.py +1 -2
- src/lilith_agent/models.py +1 -1
- src/lilith_agent/observability.py +2 -1
- src/lilith_agent/scoring_client.py +1 -1
- src/lilith_agent/tools/pdf.py +0 -1
- src/lilith_agent/tools/web.py +1 -1
- src/lilith_agent/tui.py +0 -1
- tests/test_graph.py +0 -1
- tests/test_memory_persistence.py +0 -2
- tests/test_memory_pick_up.py +0 -1
- tests/test_memory_safety.py +1 -2
- tests/test_python_sandbox.py +0 -1
- tests/test_vision.py +0 -2
src/lilith_agent/app.py
CHANGED
|
@@ -12,7 +12,7 @@ from langchain_core.tools import BaseTool
|
|
| 12 |
import os
|
| 13 |
from pathlib import Path
|
| 14 |
from langgraph.graph import END, StateGraph
|
| 15 |
-
from langgraph.graph.message import
|
| 16 |
from typing import Annotated, TypedDict
|
| 17 |
|
| 18 |
class AgentState(TypedDict):
|
|
|
|
| 12 |
import os
|
| 13 |
from pathlib import Path
|
| 14 |
from langgraph.graph import END, StateGraph
|
| 15 |
+
from langgraph.graph.message import add_messages
|
| 16 |
from typing import Annotated, TypedDict
|
| 17 |
|
| 18 |
class AgentState(TypedDict):
|
src/lilith_agent/memory.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import os
|
| 2 |
-
import json
|
| 3 |
import sqlite3
|
| 4 |
import logging
|
| 5 |
import uuid
|
|
@@ -7,7 +6,7 @@ from contextlib import contextmanager
|
|
| 7 |
from pathlib import Path
|
| 8 |
from typing import List, Dict, Any, Optional, Union
|
| 9 |
from datetime import datetime
|
| 10 |
-
from langchain_core.messages import BaseMessage,
|
| 11 |
|
| 12 |
log = logging.getLogger(__name__)
|
| 13 |
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
import sqlite3
|
| 3 |
import logging
|
| 4 |
import uuid
|
|
|
|
| 6 |
from pathlib import Path
|
| 7 |
from typing import List, Dict, Any, Optional, Union
|
| 8 |
from datetime import datetime
|
| 9 |
+
from langchain_core.messages import BaseMessage, HumanMessage
|
| 10 |
|
| 11 |
log = logging.getLogger(__name__)
|
| 12 |
|
src/lilith_agent/models.py
CHANGED
|
@@ -102,7 +102,7 @@ except ImportError:
|
|
| 102 |
if SQLiteCache:
|
| 103 |
try:
|
| 104 |
set_llm_cache(SQLiteCache(database_path=".langchain.db"))
|
| 105 |
-
except Exception
|
| 106 |
# Fail gracefully if sqlite is missing or DB file locked
|
| 107 |
pass
|
| 108 |
|
|
|
|
| 102 |
if SQLiteCache:
|
| 103 |
try:
|
| 104 |
set_llm_cache(SQLiteCache(database_path=".langchain.db"))
|
| 105 |
+
except Exception:
|
| 106 |
# Fail gracefully if sqlite is missing or DB file locked
|
| 107 |
pass
|
| 108 |
|
src/lilith_agent/observability.py
CHANGED
|
@@ -40,7 +40,8 @@ def setup_arize(project_name: str = "lilith") -> bool:
|
|
| 40 |
os.environ.setdefault("OTEL_EXPORTER_OTLP_TIMEOUT", "2")
|
| 41 |
os.environ.setdefault("OTEL_BSP_EXPORT_TIMEOUT", "2000")
|
| 42 |
|
| 43 |
-
import contextlib
|
|
|
|
| 44 |
with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()):
|
| 45 |
tracer_provider = register(
|
| 46 |
space_id=space_id,
|
|
|
|
| 40 |
os.environ.setdefault("OTEL_EXPORTER_OTLP_TIMEOUT", "2")
|
| 41 |
os.environ.setdefault("OTEL_BSP_EXPORT_TIMEOUT", "2000")
|
| 42 |
|
| 43 |
+
import contextlib
|
| 44 |
+
import io
|
| 45 |
with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()):
|
| 46 |
tracer_provider = register(
|
| 47 |
space_id=space_id,
|
src/lilith_agent/scoring_client.py
CHANGED
|
@@ -12,7 +12,7 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 12 |
log = logging.getLogger(__name__)
|
| 13 |
|
| 14 |
if TYPE_CHECKING:
|
| 15 |
-
|
| 16 |
|
| 17 |
|
| 18 |
class ScoringApiClient:
|
|
|
|
| 12 |
log = logging.getLogger(__name__)
|
| 13 |
|
| 14 |
if TYPE_CHECKING:
|
| 15 |
+
pass
|
| 16 |
|
| 17 |
|
| 18 |
class ScoringApiClient:
|
src/lilith_agent/tools/pdf.py
CHANGED
|
@@ -4,7 +4,6 @@ from pathlib import Path
|
|
| 4 |
import httpx
|
| 5 |
from pypdf import PdfReader
|
| 6 |
|
| 7 |
-
from lilith_agent.tools.vision import inspect_visual_content
|
| 8 |
|
| 9 |
|
| 10 |
def inspect_pdf(url_or_path: str, query: str) -> str:
|
|
|
|
| 4 |
import httpx
|
| 5 |
from pypdf import PdfReader
|
| 6 |
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
def inspect_pdf(url_or_path: str, query: str) -> str:
|
src/lilith_agent/tools/web.py
CHANGED
|
@@ -118,7 +118,7 @@ def fetch_url(url: str, max_chars: int = 8000, timeout: float = 60.0) -> str:
|
|
| 118 |
if resp.status_code == 200 and len(resp.text) > 50:
|
| 119 |
text = resp.text
|
| 120 |
return text[:max_chars] if len(text) > max_chars else text
|
| 121 |
-
except Exception
|
| 122 |
# Silently fail Jina attempt and proceed to fallback
|
| 123 |
pass
|
| 124 |
|
|
|
|
| 118 |
if resp.status_code == 200 and len(resp.text) > 50:
|
| 119 |
text = resp.text
|
| 120 |
return text[:max_chars] if len(text) > max_chars else text
|
| 121 |
+
except Exception:
|
| 122 |
# Silently fail Jina attempt and proceed to fallback
|
| 123 |
pass
|
| 124 |
|
src/lilith_agent/tui.py
CHANGED
|
@@ -9,7 +9,6 @@ load_dotenv(dotenv_path=env_path, override=True)
|
|
| 9 |
from rich.console import Console
|
| 10 |
from rich.panel import Panel
|
| 11 |
from rich.markdown import Markdown
|
| 12 |
-
from rich.align import Align
|
| 13 |
from rich.live import Live
|
| 14 |
from rich.spinner import Spinner
|
| 15 |
from rich.theme import Theme
|
|
|
|
| 9 |
from rich.console import Console
|
| 10 |
from rich.panel import Panel
|
| 11 |
from rich.markdown import Markdown
|
|
|
|
| 12 |
from rich.live import Live
|
| 13 |
from rich.spinner import Spinner
|
| 14 |
from rich.theme import Theme
|
tests/test_graph.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
from unittest.mock import MagicMock
|
| 2 |
|
| 3 |
from langchain_core.messages import AIMessage, HumanMessage, ToolMessage
|
| 4 |
from langchain_core.tools import tool as tool_decorator
|
|
|
|
|
|
|
| 1 |
|
| 2 |
from langchain_core.messages import AIMessage, HumanMessage, ToolMessage
|
| 3 |
from langchain_core.tools import tool as tool_decorator
|
tests/test_memory_persistence.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
import pytest
|
| 2 |
-
from pathlib import Path
|
| 3 |
import logging
|
| 4 |
from lilith_agent.config import Config
|
| 5 |
from lilith_agent.app import build_react_agent
|
|
|
|
|
|
|
|
|
|
| 1 |
import logging
|
| 2 |
from lilith_agent.config import Config
|
| 3 |
from lilith_agent.app import build_react_agent
|
tests/test_memory_pick_up.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
import os
|
| 2 |
from lilith_agent.memory import _store, retrieve_relevant_context
|
| 3 |
|
| 4 |
# Initialize DB via _store
|
|
|
|
|
|
|
| 1 |
from lilith_agent.memory import _store, retrieve_relevant_context
|
| 2 |
|
| 3 |
# Initialize DB via _store
|
tests/test_memory_safety.py
CHANGED
|
@@ -1,8 +1,7 @@
|
|
| 1 |
"""Tests for memory safety guards: empty-list wipe prevention and ID stability."""
|
| 2 |
-
import pytest
|
| 3 |
from langchain_core.messages import HumanMessage
|
| 4 |
|
| 5 |
-
from lilith_agent.memory import MemoryStore, MIN_MESSAGES_FOR_EXTRACTION
|
| 6 |
|
| 7 |
|
| 8 |
class _FakeEpisodeModel:
|
|
|
|
| 1 |
"""Tests for memory safety guards: empty-list wipe prevention and ID stability."""
|
|
|
|
| 2 |
from langchain_core.messages import HumanMessage
|
| 3 |
|
| 4 |
+
from lilith_agent.memory import MemoryStore, MIN_MESSAGES_FOR_EXTRACTION
|
| 5 |
|
| 6 |
|
| 7 |
class _FakeEpisodeModel:
|
tests/test_python_sandbox.py
CHANGED
|
@@ -251,7 +251,6 @@ def test_docker_integration_if_available(monkeypatch):
|
|
| 251 |
This test is permissive: it skips if the image isn't built (common in CI).
|
| 252 |
"""
|
| 253 |
import subprocess as sp
|
| 254 |
-
from lilith_agent.tools import python_exec as pe
|
| 255 |
|
| 256 |
image = "lilith-pysandbox:latest"
|
| 257 |
inspect = sp.run(
|
|
|
|
| 251 |
This test is permissive: it skips if the image isn't built (common in CI).
|
| 252 |
"""
|
| 253 |
import subprocess as sp
|
|
|
|
| 254 |
|
| 255 |
image = "lilith-pysandbox:latest"
|
| 256 |
inspect = sp.run(
|
tests/test_vision.py
CHANGED
|
@@ -1,12 +1,10 @@
|
|
| 1 |
import os
|
| 2 |
-
import pytest
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
|
| 5 |
# Load .env before evaluating anything
|
| 6 |
load_dotenv(override=True)
|
| 7 |
|
| 8 |
from lilith_agent.config import Config
|
| 9 |
-
from lilith_agent.gaia_dataset import GaiaDatasetClient
|
| 10 |
from lilith_agent.tools.vision import inspect_visual_content
|
| 11 |
|
| 12 |
def test_fal_vision_integration(tmp_path):
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
from dotenv import load_dotenv
|
| 3 |
|
| 4 |
# Load .env before evaluating anything
|
| 5 |
load_dotenv(override=True)
|
| 6 |
|
| 7 |
from lilith_agent.config import Config
|
|
|
|
| 8 |
from lilith_agent.tools.vision import inspect_visual_content
|
| 9 |
|
| 10 |
def test_fal_vision_integration(tmp_path):
|