XQ commited on
Commit
db45c50
·
1 Parent(s): 0cbf970

Code cleaning

Browse files
src/agent/plan_and_execute.py CHANGED
@@ -20,14 +20,14 @@ import re
20
  from collections.abc import Generator
21
  from typing import TypedDict
22
 
23
- from langchain_core.messages import AIMessage, HumanMessage, SystemMessage, ToolMessage
24
  from langchain_core.runnables import Runnable
25
  from langgraph.graph import END, StateGraph
26
  from langgraph.prebuilt import create_react_agent
27
 
28
  from src.agent.memory import ConversationMemory
29
  from src.agent.tools import ToolResultStore, detect_document_languages, make_retrieval_tools
30
- from src.models import GenerationResponse, IntentType, PipelineDetails, QueryResult
31
  from src.retrieval.hybrid import HybridRetriever
32
  from src.retrieval.reranker import Reranker
33
  from src.retrieval.vector_store import VectorStore
@@ -570,7 +570,7 @@ def _parse_plan(raw: str) -> list[PlanStep]:
570
  if cleaned.startswith("```"):
571
  lines = cleaned.splitlines()
572
  # Remove opening and closing fences
573
- lines = [l for l in lines if not l.strip().startswith("```")]
574
  cleaned = "\n".join(lines).strip()
575
 
576
  try:
 
20
  from collections.abc import Generator
21
  from typing import TypedDict
22
 
23
+ from langchain_core.messages import AIMessage, HumanMessage, SystemMessage
24
  from langchain_core.runnables import Runnable
25
  from langgraph.graph import END, StateGraph
26
  from langgraph.prebuilt import create_react_agent
27
 
28
  from src.agent.memory import ConversationMemory
29
  from src.agent.tools import ToolResultStore, detect_document_languages, make_retrieval_tools
30
+ from src.models import GenerationResponse, IntentType, PipelineDetails
31
  from src.retrieval.hybrid import HybridRetriever
32
  from src.retrieval.reranker import Reranker
33
  from src.retrieval.vector_store import VectorStore
 
570
  if cleaned.startswith("```"):
571
  lines = cleaned.splitlines()
572
  # Remove opening and closing fences
573
+ lines = [line for line in lines if not line.strip().startswith("```")]
574
  cleaned = "\n".join(lines).strip()
575
 
576
  try:
src/ui/app.py CHANGED
@@ -268,7 +268,7 @@ elif "session_id" not in st.session_state:
268
  # through innerHTML never execute (HTML5 spec). We instead use a tiny iframe
269
  # bootstrap (via components.html) that attaches the real Umami script to the
270
  # parent document, so analytics track the actual Streamlit page URL.
271
- import streamlit.components.v1 as components
272
 
273
  components.html(
274
  """
 
268
  # through innerHTML never execute (HTML5 spec). We instead use a tiny iframe
269
  # bootstrap (via components.html) that attaches the real Umami script to the
270
  # parent document, so analytics track the actual Streamlit page URL.
271
+ import streamlit.components.v1 as components # noqa: E402
272
 
273
  components.html(
274
  """
tests/test_api.py CHANGED
@@ -5,7 +5,7 @@ from unittest.mock import MagicMock, patch
5
  import pytest
6
  from fastapi.testclient import TestClient
7
 
8
- from src.api.routes import router, set_dependencies, QueryResponse, HealthResponse, ReadinessResponse
9
  from src.models import DocumentChunk, GenerationResponse, IntentType, QueryResult
10
 
11
 
 
5
  import pytest
6
  from fastapi.testclient import TestClient
7
 
8
+ from src.api.routes import router, set_dependencies
9
  from src.models import DocumentChunk, GenerationResponse, IntentType, QueryResult
10
 
11
 
tests/test_config.py CHANGED
@@ -1,6 +1,6 @@
1
  """Tests for src.config."""
2
 
3
- from src.config import Settings, load_settings
4
 
5
 
6
  class TestSettings:
 
1
  """Tests for src.config."""
2
 
3
+ from src.config import Settings, load_settings # noqa: F401
4
 
5
 
6
  class TestSettings:
tests/test_embedder.py CHANGED
@@ -2,8 +2,6 @@
2
 
3
  from unittest.mock import MagicMock
4
 
5
- import pytest
6
-
7
  from src.retrieval.embedder import Embedder
8
 
9
  EMBEDDING_DIM = 384
 
2
 
3
  from unittest.mock import MagicMock
4
 
 
 
5
  from src.retrieval.embedder import Embedder
6
 
7
  EMBEDDING_DIM = 384
tests/test_hybrid.py CHANGED
@@ -4,7 +4,7 @@ from unittest.mock import MagicMock
4
 
5
  import pytest
6
 
7
- from src.models import ChunkStrategy, DocumentChunk, QueryResult
8
  from src.retrieval.hybrid import HybridRetriever
9
 
10
 
 
4
 
5
  import pytest
6
 
7
+ from src.models import DocumentChunk, QueryResult
8
  from src.retrieval.hybrid import HybridRetriever
9
 
10
 
tests/test_memory.py CHANGED
@@ -1,7 +1,5 @@
1
  """Tests for conversation memory."""
2
 
3
- import pytest
4
-
5
  from src.agent.memory import ConversationMemory, Turn
6
  from src.models import DocumentChunk, QueryResult
7
 
 
1
  """Tests for conversation memory."""
2
 
 
 
3
  from src.agent.memory import ConversationMemory, Turn
4
  from src.models import DocumentChunk, QueryResult
5
 
tests/test_models.py CHANGED
@@ -1,6 +1,6 @@
1
  """Tests for src.models."""
2
 
3
- from src.models import DocumentChunk, QueryResult, GenerationResponse, ChunkStrategy, IntentType
4
 
5
 
6
  class TestDocumentChunk:
 
1
  """Tests for src.models."""
2
 
3
+ from src.models import DocumentChunk, QueryResult, GenerationResponse, ChunkStrategy, IntentType # noqa: F401
4
 
5
 
6
  class TestDocumentChunk:
tests/test_plan_and_execute.py CHANGED
@@ -3,8 +3,6 @@
3
  from unittest.mock import MagicMock, patch
4
  import json
5
 
6
- import pytest
7
-
8
  from src.agent.plan_and_execute import (
9
  PlanAndExecuteRouter,
10
  PlanExecState,
 
3
  from unittest.mock import MagicMock, patch
4
  import json
5
 
 
 
6
  from src.agent.plan_and_execute import (
7
  PlanAndExecuteRouter,
8
  PlanExecState,
tests/test_reranker.py CHANGED
@@ -1,6 +1,5 @@
1
  """Tests for the cross-encoder reranker."""
2
 
3
- import math
4
  from unittest.mock import MagicMock
5
 
6
  import numpy as np
 
1
  """Tests for the cross-encoder reranker."""
2
 
 
3
  from unittest.mock import MagicMock
4
 
5
  import numpy as np
tests/test_session_store.py CHANGED
@@ -1,11 +1,7 @@
1
  """Tests for the SQLite-backed session store."""
2
 
3
  import os
4
- import tempfile
5
 
6
- import pytest
7
-
8
- from src.agent.memory import ConversationMemory
9
  from src.agent.session_store import SessionStore
10
  from src.models import DocumentChunk, QueryResult
11
 
 
1
  """Tests for the SQLite-backed session store."""
2
 
3
  import os
 
4
 
 
 
 
5
  from src.agent.session_store import SessionStore
6
  from src.models import DocumentChunk, QueryResult
7
 
tests/test_vector_store.py CHANGED
@@ -1,7 +1,5 @@
1
  """Tests for the Qdrant vector store."""
2
 
3
- import tempfile
4
-
5
  import pytest
6
 
7
  from src.models import ChunkStrategy, DocumentChunk
 
1
  """Tests for the Qdrant vector store."""
2
 
 
 
3
  import pytest
4
 
5
  from src.models import ChunkStrategy, DocumentChunk