Skip to content

Commit 126e711

Browse files
committed
fix: ruff lint errors from merge
1 parent a534ce4 commit 126e711

16 files changed

Lines changed: 115 additions & 80 deletions

File tree

tests/unit/test_factory.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
import pytest
44

55
from vektori.models.anthropic import AnthropicLLM
6-
from vektori.models.factory import CHAT_REGISTRY, LLM_REGISTRY, create_chat_model, create_embedder, create_llm
6+
from vektori.models.factory import (
7+
CHAT_REGISTRY,
8+
LLM_REGISTRY,
9+
create_chat_model,
10+
create_embedder,
11+
create_llm,
12+
)
713
from vektori.models.nvidia import DEFAULT_EMBEDDING_MODEL, NvidiaEmbedder, NvidiaLLM
814
from vektori.models.ollama import OllamaEmbedder, OllamaLLM
915
from vektori.models.openai import OpenAIEmbedder, OpenAILLM

tests/unit/test_tools.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from vektori.models.base import ChatCompletionResult
1212
from vektori.tools.memory import MEMORY_TOOLS, handle_tool_call
1313

14-
1514
# — Tool schema tests —
1615

1716
def test_memory_tools_has_three_tools():
@@ -70,8 +69,7 @@ async def test_handle_get_profile_empty():
7069

7170
@pytest.mark.asyncio
7271
async def test_handle_get_profile_with_patches():
73-
from datetime import datetime, timezone
74-
from vektori.memory.profile import InMemoryProfileStore, ProfilePatch
72+
from vektori.memory.profile import ProfilePatch
7573

7674
store = InMemoryProfileStore()
7775
await store.save(ProfilePatch(

tests/unit/test_window_persistence.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from vektori.memory.window import MessageWindow, SQLiteWindowStore, WindowState
1111
from vektori.models.base import ChatCompletionResult
1212

13-
1413
# — SQLiteWindowStore tests —
1514

1615
@pytest.mark.asyncio

uv.lock

Lines changed: 34 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vektori/agent.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
from __future__ import annotations
44

55
import asyncio
6+
import re
67
from dataclasses import dataclass, field
78
from pathlib import Path
8-
import re
99
from typing import Any
1010
from uuid import uuid4
1111

1212
from vektori.client import Vektori
1313
from vektori.context import AgentContextLoader
14-
from vektori.memory.profile import InMemoryProfileStore, ProfilePatch, ProfileStore, SQLiteProfileStore
14+
from vektori.memory.profile import (
15+
InMemoryProfileStore,
16+
ProfilePatch,
17+
ProfileStore,
18+
SQLiteProfileStore,
19+
)
1520
from vektori.memory.window import MessageWindow, SQLiteWindowStore
1621
from vektori.models.base import ChatModelProvider
1722
from vektori.prompts import build_prompt_result

vektori/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,16 @@ async def add_document(
220220
Maps source:source_id -> deterministic session_id so re-ingestion upserts, not duplicates.
221221
"""
222222
session_id = f"{source}:{source_id}"
223-
223+
224224
doc_metadata = metadata or {}
225225
doc_metadata.update({
226226
"source": source,
227227
"source_id": source_id,
228228
"type": "document",
229229
})
230-
230+
231231
messages = [{"role": "user", "content": content}]
232-
232+
233233
return await self.add(
234234
messages=messages,
235235
session_id=session_id,

vektori/connectors/auth.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44
import os
55
from pathlib import Path
6-
from typing import Any, Dict, List, Optional
6+
from typing import Any
77

88

99
class AuthStore:
@@ -20,13 +20,13 @@ def __init__(self, base_dir: str | None = None) -> None:
2020
def _get_path(self, user_id: str, platform: str) -> Path:
2121
return self.base_dir / user_id / f"{platform}.json"
2222

23-
def get_token(self, user_id: str, platform: str) -> Optional[Dict[str, Any]]:
23+
def get_token(self, user_id: str, platform: str) -> dict[str, Any] | None:
2424
"""Retrieve the authentication details for a specific user and platform."""
2525
path = self._get_path(user_id, platform)
2626
if not path.exists():
2727
return None
2828
try:
29-
with open(path, "r", encoding="utf-8") as f:
29+
with open(path, encoding="utf-8") as f:
3030
return json.load(f)
3131
except json.JSONDecodeError:
3232
return None
@@ -36,9 +36,9 @@ def set_token(
3636
user_id: str,
3737
platform: str,
3838
access_token: str,
39-
refresh_token: Optional[str] = None,
40-
expiry: Optional[str] = None,
41-
scopes: Optional[List[str]] = None,
39+
refresh_token: str | None = None,
40+
expiry: str | None = None,
41+
scopes: list[str] | None = None,
4242
) -> None:
4343
"""Save the authentication details securely."""
4444
path = self._get_path(user_id, platform)

vektori/connectors/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
from __future__ import annotations
44

5-
from typing import TYPE_CHECKING, Any, Callable, Protocol
5+
from collections.abc import Callable
66
from datetime import datetime
7+
from typing import TYPE_CHECKING, Any, Protocol
78

89
if TYPE_CHECKING:
910
from vektori.client import Vektori

vektori/connectors/github.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,36 +57,36 @@ async def ingest(
5757

5858
try:
5959
repo = g.get_repo(self.repo_name)
60-
60+
6161
kwargs: dict[str, Any] = {"state": "all"}
6262
if since:
6363
kwargs["since"] = since
64-
64+
6565
issues = repo.get_issues(**kwargs)
6666

6767
for issue in issues:
6868
# We want to skip raw pull requests if we just want issues
6969
# (PyGithub returns PRs as issues too, but we can detect them)
70-
70+
7171
source_id = f"{self.repo_name}/issues/{issue.number}"
72-
72+
7373
# Combine issue body and comments into a readable chronological "document"
7474
content_parts = [
7575
f"Title: {issue.title}",
7676
f"State: {issue.state}",
7777
f"Author: {issue.user.login}",
7878
f"Body:\n{issue.body or 'No description provided.'}",
7979
]
80-
80+
8181
comments = issue.get_comments()
8282
for comment in comments:
8383
content_parts.append(
8484
f"\n--- Comment by {comment.user.login} at {comment.created_at} ---\n{comment.body}"
8585
)
86-
86+
8787
document_content = "\n".join(content_parts)
8888
document_time = issue.updated_at.replace(tzinfo=timezone.utc)
89-
89+
9090
# Insert into Vektori
9191
await vektori.add_document(
9292
content=document_content,
@@ -103,7 +103,7 @@ async def ingest(
103103
"is_pr": issue.pull_request is not None,
104104
}
105105
)
106-
106+
107107
count += 1
108108
logger.debug(f"Ingested GitHub issue: {source_id}")
109109

vektori/integrations/hermes.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Hermes Agent memory provider integration for Vektori."""
22

3-
from typing import Dict, List, Any
4-
import asyncio
3+
from typing import Any
54

65
# Assuming a mock BaseMemoryProvider that Hermes Agent uses
76
try:
@@ -12,44 +11,45 @@ class BaseMemoryProvider:
1211

1312
from vektori import Vektori
1413

14+
1515
class VektoriHermesMemory(BaseMemoryProvider):
1616
"""
1717
Vektori's episodic graph memory as a Hermes Memory Provider.
1818
Provides semantic recall that feeds into Hermes' self-improvement loop.
1919
"""
20-
20+
2121
def __init__(self, vektori_instance: Vektori, user_id: str):
2222
self.memory = vektori_instance
2323
self.user_id = user_id
24-
25-
async def add_memory(self, text: str, metadata: Dict[str, Any] = None) -> str:
24+
25+
async def add_memory(self, text: str, metadata: dict[str, Any] = None) -> str:
2626
"""Store a new fact/episode from the Hermes agent into Vektori."""
2727
result = await self.memory.add(
2828
messages=[{"role": "user", "content": text}],
2929
user_id=self.user_id,
3030
metadata=metadata
3131
)
3232
return result.get('status', 'success')
33-
34-
async def search_memory(self, query: str, limit: int = 5) -> List[Dict[str, Any]]:
33+
34+
async def search_memory(self, query: str, limit: int = 5) -> list[dict[str, Any]]:
3535
"""Retrieve L1 (Facts + Episodes) depth context for Hermes prompt injection."""
3636
results = await self.memory.search(
37-
query=query,
38-
user_id=self.user_id,
37+
query=query,
38+
user_id=self.user_id,
3939
depth="l1",
4040
top_k=limit
4141
)
42-
42+
4343
# Hermes usually expects a flat list of memory dicts
4444
memories = []
4545
for f in results.get("facts", []):
4646
memories.append({"type": "fact", "content": f["text"], "score": f.get("score")})
4747
for ep in results.get("episodes", []):
4848
memories.append({"type": "episode", "content": ep["text"], "score": 1.0})
49-
49+
5050
return memories
5151

5252
async def clear(self) -> None:
5353
"""Clear memory for the current user."""
54-
# Vektori users would need an explicit delete endpoint,
54+
# Vektori users would need an explicit delete endpoint,
5555
pass

0 commit comments

Comments
 (0)