style(librarian): apply ruff autofixes to client and tools
Mechanical Optional[X] -> X | None and f-string cleanups so subsequent librarian changes lint clean against the dirty baseline. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ Provides async methods for all relevant library-desk endpoints:
|
|||||||
- Vector search
|
- Vector search
|
||||||
- Knowledge graph queries
|
- Knowledge graph queries
|
||||||
"""
|
"""
|
||||||
from typing import Any, Optional
|
from typing import Any
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
@@ -28,11 +28,11 @@ class WikiPage(BaseModel):
|
|||||||
id: int
|
id: int
|
||||||
path: str
|
path: str
|
||||||
title: str
|
title: str
|
||||||
description: Optional[str] = None
|
description: str | None = None
|
||||||
content: Optional[str] = None
|
content: str | None = None
|
||||||
tags: list[str] = Field(default_factory=list)
|
tags: list[str] = Field(default_factory=list)
|
||||||
created_at: Optional[str] = None
|
created_at: str | None = None
|
||||||
updated_at: Optional[str] = None
|
updated_at: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class WikiSearchResult(BaseModel):
|
class WikiSearchResult(BaseModel):
|
||||||
@@ -40,8 +40,8 @@ class WikiSearchResult(BaseModel):
|
|||||||
id: int
|
id: int
|
||||||
path: str
|
path: str
|
||||||
title: str
|
title: str
|
||||||
description: Optional[str] = None
|
description: str | None = None
|
||||||
locale: Optional[str] = None
|
locale: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class VectorSearchResult(BaseModel):
|
class VectorSearchResult(BaseModel):
|
||||||
@@ -59,9 +59,9 @@ class HybridSearchResult(BaseModel):
|
|||||||
source: str # "vector", "graph", "web"
|
source: str # "vector", "graph", "web"
|
||||||
title: str
|
title: str
|
||||||
content: str
|
content: str
|
||||||
url: Optional[str] = None
|
url: str | None = None
|
||||||
score: float
|
score: float
|
||||||
page_id: Optional[int] = None
|
page_id: int | None = None
|
||||||
metadata: dict[str, Any] = Field(default_factory=dict)
|
metadata: dict[str, Any] = Field(default_factory=dict)
|
||||||
|
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ class HybridRAGResponse(BaseModel):
|
|||||||
synonyms: list[str] = Field(default_factory=list)
|
synonyms: list[str] = Field(default_factory=list)
|
||||||
related_dossiers: list[str] = Field(default_factory=list)
|
related_dossiers: list[str] = Field(default_factory=list)
|
||||||
formatted_context: str = ""
|
formatted_context: str = ""
|
||||||
search_id: Optional[str] = None
|
search_id: str | None = None
|
||||||
timing: dict[str, float] = Field(default_factory=dict)
|
timing: dict[str, float] = Field(default_factory=dict)
|
||||||
|
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ class WebSearchResult(BaseModel):
|
|||||||
content: str = "" # Full extracted text via Trafilatura
|
content: str = "" # Full extracted text via Trafilatura
|
||||||
snippet: str = "" # Original search engine snippet
|
snippet: str = "" # Original search engine snippet
|
||||||
source: str = "" # Domain name
|
source: str = "" # Domain name
|
||||||
published_date: Optional[str] = None
|
published_date: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class WebSearchResponse(BaseModel):
|
class WebSearchResponse(BaseModel):
|
||||||
@@ -121,13 +121,13 @@ class WebSearchResponse(BaseModel):
|
|||||||
class ContentExtractionResult(BaseModel):
|
class ContentExtractionResult(BaseModel):
|
||||||
"""Result from content extraction."""
|
"""Result from content extraction."""
|
||||||
url: str
|
url: str
|
||||||
title: Optional[str] = None
|
title: str | None = None
|
||||||
content: str = ""
|
content: str = ""
|
||||||
author: Optional[str] = None
|
author: str | None = None
|
||||||
date: Optional[str] = None
|
date: str | None = None
|
||||||
language: Optional[str] = None
|
language: str | None = None
|
||||||
success: bool = True
|
success: bool = True
|
||||||
error: Optional[str] = None
|
error: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class BatchExtractionResponse(BaseModel):
|
class BatchExtractionResponse(BaseModel):
|
||||||
@@ -151,7 +151,7 @@ class SmartCreateResponse(BaseModel):
|
|||||||
page: WikiPage
|
page: WikiPage
|
||||||
research_summary: ResearchSummary = Field(default_factory=ResearchSummary)
|
research_summary: ResearchSummary = Field(default_factory=ResearchSummary)
|
||||||
sources_used: int = 0
|
sources_used: int = 0
|
||||||
search_id: Optional[str] = None
|
search_id: str | None = None
|
||||||
entity_linking: EntityLinking = Field(default_factory=EntityLinking)
|
entity_linking: EntityLinking = Field(default_factory=EntityLinking)
|
||||||
|
|
||||||
|
|
||||||
@@ -170,8 +170,8 @@ class LibraryDeskClient:
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
base_url: Optional[str] = None,
|
base_url: str | None = None,
|
||||||
api_key: Optional[str] = None,
|
api_key: str | None = None,
|
||||||
timeout: int = 60,
|
timeout: int = 60,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
@@ -185,7 +185,7 @@ class LibraryDeskClient:
|
|||||||
self.base_url = base_url or str(config.LIBRARY_DESK_HOST)
|
self.base_url = base_url or str(config.LIBRARY_DESK_HOST)
|
||||||
self.api_key = api_key or config.LIBRARY_DESK_API_KEY
|
self.api_key = api_key or config.LIBRARY_DESK_API_KEY
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
self._client: Optional[httpx.AsyncClient] = None
|
self._client: httpx.AsyncClient | None = None
|
||||||
|
|
||||||
async def __aenter__(self) -> "LibraryDeskClient":
|
async def __aenter__(self) -> "LibraryDeskClient":
|
||||||
"""Create HTTP client on context entry."""
|
"""Create HTTP client on context entry."""
|
||||||
@@ -371,7 +371,7 @@ class LibraryDeskClient:
|
|||||||
async def list_wiki_pages(
|
async def list_wiki_pages(
|
||||||
self,
|
self,
|
||||||
user: str | None = None,
|
user: str | None = None,
|
||||||
tag: Optional[str] = None,
|
tag: str | None = None,
|
||||||
limit: int = 50,
|
limit: int = 50,
|
||||||
) -> list[WikiPage]:
|
) -> list[WikiPage]:
|
||||||
"""
|
"""
|
||||||
@@ -405,7 +405,7 @@ class LibraryDeskClient:
|
|||||||
content: str,
|
content: str,
|
||||||
user: str | None = None,
|
user: str | None = None,
|
||||||
description: str = "",
|
description: str = "",
|
||||||
tags: Optional[list[str]] = None,
|
tags: list[str] | None = None,
|
||||||
) -> WikiPage:
|
) -> WikiPage:
|
||||||
"""
|
"""
|
||||||
Create a new wiki page.
|
Create a new wiki page.
|
||||||
@@ -444,10 +444,10 @@ class LibraryDeskClient:
|
|||||||
self,
|
self,
|
||||||
page_id: int,
|
page_id: int,
|
||||||
user: str | None = None,
|
user: str | None = None,
|
||||||
content: Optional[str] = None,
|
content: str | None = None,
|
||||||
title: Optional[str] = None,
|
title: str | None = None,
|
||||||
tags: Optional[list[str]] = None,
|
tags: list[str] | None = None,
|
||||||
description: Optional[str] = None,
|
description: str | None = None,
|
||||||
) -> WikiPage:
|
) -> WikiPage:
|
||||||
"""
|
"""
|
||||||
Update an existing wiki page.
|
Update an existing wiki page.
|
||||||
@@ -500,7 +500,7 @@ class LibraryDeskClient:
|
|||||||
topic: str,
|
topic: str,
|
||||||
tags: list[str],
|
tags: list[str],
|
||||||
user: str | None = None,
|
user: str | None = None,
|
||||||
path: Optional[str] = None,
|
path: str | None = None,
|
||||||
include_web_research: bool = True,
|
include_web_research: bool = True,
|
||||||
include_wiki_search: bool = True,
|
include_wiki_search: bool = True,
|
||||||
) -> SmartCreateResponse:
|
) -> SmartCreateResponse:
|
||||||
@@ -636,7 +636,7 @@ class LibraryDeskClient:
|
|||||||
self,
|
self,
|
||||||
cypher_query: str,
|
cypher_query: str,
|
||||||
user: str | None = None,
|
user: str | None = None,
|
||||||
parameters: Optional[dict[str, Any]] = None,
|
parameters: dict[str, Any] | None = None,
|
||||||
) -> list[dict[str, Any]]:
|
) -> list[dict[str, Any]]:
|
||||||
"""
|
"""
|
||||||
Execute a Cypher query on the knowledge graph.
|
Execute a Cypher query on the knowledge graph.
|
||||||
@@ -670,7 +670,7 @@ class LibraryDeskClient:
|
|||||||
async def list_graph_nodes(
|
async def list_graph_nodes(
|
||||||
self,
|
self,
|
||||||
user: str | None = None,
|
user: str | None = None,
|
||||||
node_type: Optional[str] = None,
|
node_type: str | None = None,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
) -> list[GraphNode]:
|
) -> list[GraphNode]:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -635,7 +635,7 @@ async def read_urls_batch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
output_parts = [
|
output_parts = [
|
||||||
f"## Batch Content Extraction",
|
"## Batch Content Extraction",
|
||||||
f"*Extracted {response.successful}/{response.total_urls} URLs in {response.extraction_time_ms}ms*\n",
|
f"*Extracted {response.successful}/{response.total_urls} URLs in {response.extraction_time_ms}ms*\n",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user