kodit 0.3.12__py3-none-any.whl → 0.3.14__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of kodit might be problematic. Click here for more details.
- kodit/_version.py +2 -2
- kodit/app.py +2 -1
- kodit/config.py +12 -3
- kodit/infrastructure/embedding/embedding_factory.py +2 -0
- kodit/infrastructure/embedding/embedding_providers/openai_embedding_provider.py +7 -3
- kodit/infrastructure/enrichment/enrichment_factory.py +2 -0
- kodit/infrastructure/enrichment/openai_enrichment_provider.py +8 -2
- kodit/log.py +1 -9
- {kodit-0.3.12.dist-info → kodit-0.3.14.dist-info}/METADATA +1 -1
- {kodit-0.3.12.dist-info → kodit-0.3.14.dist-info}/RECORD +13 -13
- {kodit-0.3.12.dist-info → kodit-0.3.14.dist-info}/WHEEL +0 -0
- {kodit-0.3.12.dist-info → kodit-0.3.14.dist-info}/entry_points.txt +0 -0
- {kodit-0.3.12.dist-info → kodit-0.3.14.dist-info}/licenses/LICENSE +0 -0
kodit/_version.py
CHANGED
kodit/app.py
CHANGED
|
@@ -26,10 +26,11 @@ async def app_lifespan(_: FastAPI) -> AsyncIterator[AppLifespanState]:
|
|
|
26
26
|
"""Manage application lifespan for auto-indexing and sync."""
|
|
27
27
|
global _auto_indexing_service, _sync_scheduler_service # noqa: PLW0603
|
|
28
28
|
|
|
29
|
+
# App context has already been configured by the CLI.
|
|
29
30
|
app_context = AppContext()
|
|
30
|
-
db = await app_context.get_db()
|
|
31
31
|
|
|
32
32
|
# Start auto-indexing service
|
|
33
|
+
db = await app_context.get_db()
|
|
33
34
|
_auto_indexing_service = AutoIndexingService(
|
|
34
35
|
app_context=app_context,
|
|
35
36
|
session_factory=db.session_factory,
|
kodit/config.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import asyncio
|
|
6
|
+
from enum import Enum
|
|
6
7
|
from functools import wraps
|
|
7
8
|
from pathlib import Path
|
|
8
9
|
from typing import TYPE_CHECKING, Annotated, Any, Literal, TypeVar
|
|
@@ -18,15 +19,22 @@ from pydantic_settings import (
|
|
|
18
19
|
SettingsConfigDict,
|
|
19
20
|
)
|
|
20
21
|
|
|
22
|
+
from kodit.database import Database
|
|
23
|
+
|
|
21
24
|
if TYPE_CHECKING:
|
|
22
25
|
from collections.abc import Callable, Coroutine
|
|
23
26
|
|
|
24
27
|
|
|
25
|
-
|
|
28
|
+
class LogFormat(Enum):
|
|
29
|
+
"""The format of the log output."""
|
|
30
|
+
|
|
31
|
+
PRETTY = "pretty"
|
|
32
|
+
JSON = "json"
|
|
33
|
+
|
|
26
34
|
|
|
27
35
|
DEFAULT_BASE_DIR = Path.home() / ".kodit"
|
|
28
36
|
DEFAULT_LOG_LEVEL = "INFO"
|
|
29
|
-
DEFAULT_LOG_FORMAT =
|
|
37
|
+
DEFAULT_LOG_FORMAT = LogFormat.PRETTY
|
|
30
38
|
DEFAULT_DISABLE_TELEMETRY = False
|
|
31
39
|
T = TypeVar("T")
|
|
32
40
|
|
|
@@ -40,6 +48,7 @@ class Endpoint(BaseModel):
|
|
|
40
48
|
base_url: str | None = None
|
|
41
49
|
model: str | None = None
|
|
42
50
|
api_key: str | None = None
|
|
51
|
+
num_parallel_tasks: int | None = None
|
|
43
52
|
|
|
44
53
|
|
|
45
54
|
class Search(BaseModel):
|
|
@@ -165,7 +174,7 @@ class AppContext(BaseSettings):
|
|
|
165
174
|
default_factory=lambda data: f"sqlite+aiosqlite:///{data['data_dir']}/kodit.db"
|
|
166
175
|
)
|
|
167
176
|
log_level: str = Field(default=DEFAULT_LOG_LEVEL)
|
|
168
|
-
log_format:
|
|
177
|
+
log_format: LogFormat = Field(default=DEFAULT_LOG_FORMAT)
|
|
169
178
|
disable_telemetry: bool = Field(default=DEFAULT_DISABLE_TELEMETRY)
|
|
170
179
|
default_endpoint: Endpoint | None = Field(
|
|
171
180
|
default=None,
|
|
@@ -14,6 +14,7 @@ from kodit.infrastructure.embedding.embedding_providers.local_embedding_provider
|
|
|
14
14
|
LocalEmbeddingProvider,
|
|
15
15
|
)
|
|
16
16
|
from kodit.infrastructure.embedding.embedding_providers.openai_embedding_provider import ( # noqa: E501
|
|
17
|
+
OPENAI_NUM_PARALLEL_TASKS,
|
|
17
18
|
OpenAIEmbeddingProvider,
|
|
18
19
|
)
|
|
19
20
|
from kodit.infrastructure.embedding.local_vector_search_repository import (
|
|
@@ -55,6 +56,7 @@ def embedding_domain_service_factory(
|
|
|
55
56
|
max_retries=2,
|
|
56
57
|
),
|
|
57
58
|
model_name=endpoint.model or "text-embedding-3-small",
|
|
59
|
+
num_parallel_tasks=endpoint.num_parallel_tasks or OPENAI_NUM_PARALLEL_TASKS,
|
|
58
60
|
)
|
|
59
61
|
else:
|
|
60
62
|
log_event("kodit.embedding", {"provider": "local"})
|
|
@@ -18,14 +18,17 @@ MAX_TOKENS = 8192 # Conservative token limit for the embedding model
|
|
|
18
18
|
BATCH_SIZE = (
|
|
19
19
|
10 # Maximum number of items per API call (keeps existing test expectations)
|
|
20
20
|
)
|
|
21
|
-
OPENAI_NUM_PARALLEL_TASKS =
|
|
21
|
+
OPENAI_NUM_PARALLEL_TASKS = 10 # Semaphore limit for concurrent OpenAI requests
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
class OpenAIEmbeddingProvider(EmbeddingProvider):
|
|
25
25
|
"""OpenAI embedding provider that uses OpenAI's embedding API."""
|
|
26
26
|
|
|
27
27
|
def __init__(
|
|
28
|
-
self,
|
|
28
|
+
self,
|
|
29
|
+
openai_client: AsyncOpenAI,
|
|
30
|
+
model_name: str = "text-embedding-3-small",
|
|
31
|
+
num_parallel_tasks: int = OPENAI_NUM_PARALLEL_TASKS,
|
|
29
32
|
) -> None:
|
|
30
33
|
"""Initialize the OpenAI embedding provider.
|
|
31
34
|
|
|
@@ -36,6 +39,7 @@ class OpenAIEmbeddingProvider(EmbeddingProvider):
|
|
|
36
39
|
"""
|
|
37
40
|
self.openai_client = openai_client
|
|
38
41
|
self.model_name = model_name
|
|
42
|
+
self.num_parallel_tasks = num_parallel_tasks
|
|
39
43
|
self.log = structlog.get_logger(__name__)
|
|
40
44
|
|
|
41
45
|
# Lazily initialised token encoding
|
|
@@ -78,7 +82,7 @@ class OpenAIEmbeddingProvider(EmbeddingProvider):
|
|
|
78
82
|
# Process batches concurrently (but bounded by a semaphore)
|
|
79
83
|
# -----------------------------------------------------------------
|
|
80
84
|
|
|
81
|
-
sem = asyncio.Semaphore(
|
|
85
|
+
sem = asyncio.Semaphore(self.num_parallel_tasks)
|
|
82
86
|
|
|
83
87
|
async def _process_batch(
|
|
84
88
|
batch: list[EmbeddingRequest],
|
|
@@ -9,6 +9,7 @@ from kodit.infrastructure.enrichment.local_enrichment_provider import (
|
|
|
9
9
|
LocalEnrichmentProvider,
|
|
10
10
|
)
|
|
11
11
|
from kodit.infrastructure.enrichment.openai_enrichment_provider import (
|
|
12
|
+
OPENAI_NUM_PARALLEL_TASKS,
|
|
12
13
|
OpenAIEnrichmentProvider,
|
|
13
14
|
)
|
|
14
15
|
from kodit.log import log_event
|
|
@@ -54,6 +55,7 @@ def enrichment_domain_service_factory(
|
|
|
54
55
|
max_retries=2,
|
|
55
56
|
),
|
|
56
57
|
model_name=endpoint.model or "gpt-4o-mini",
|
|
58
|
+
num_parallel_tasks=endpoint.num_parallel_tasks or OPENAI_NUM_PARALLEL_TASKS,
|
|
57
59
|
)
|
|
58
60
|
else:
|
|
59
61
|
log_event("kodit.enrichment", {"provider": "local"})
|
|
@@ -21,7 +21,12 @@ OPENAI_NUM_PARALLEL_TASKS = 40
|
|
|
21
21
|
class OpenAIEnrichmentProvider(EnrichmentProvider):
|
|
22
22
|
"""OpenAI enrichment provider implementation."""
|
|
23
23
|
|
|
24
|
-
def __init__(
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
openai_client: Any,
|
|
27
|
+
model_name: str = "gpt-4o-mini",
|
|
28
|
+
num_parallel_tasks: int = OPENAI_NUM_PARALLEL_TASKS,
|
|
29
|
+
) -> None:
|
|
25
30
|
"""Initialize the OpenAI enrichment provider.
|
|
26
31
|
|
|
27
32
|
Args:
|
|
@@ -32,6 +37,7 @@ class OpenAIEnrichmentProvider(EnrichmentProvider):
|
|
|
32
37
|
self.log = structlog.get_logger(__name__)
|
|
33
38
|
self.openai_client = openai_client
|
|
34
39
|
self.model_name = model_name
|
|
40
|
+
self.num_parallel_tasks = num_parallel_tasks
|
|
35
41
|
|
|
36
42
|
async def enrich(
|
|
37
43
|
self, requests: list[EnrichmentRequest]
|
|
@@ -50,7 +56,7 @@ class OpenAIEnrichmentProvider(EnrichmentProvider):
|
|
|
50
56
|
return
|
|
51
57
|
|
|
52
58
|
# Process batches in parallel with a semaphore to limit concurrent requests
|
|
53
|
-
sem = asyncio.Semaphore(
|
|
59
|
+
sem = asyncio.Semaphore(self.num_parallel_tasks)
|
|
54
60
|
|
|
55
61
|
async def process_request(request: EnrichmentRequest) -> EnrichmentResponse:
|
|
56
62
|
async with sem:
|
kodit/log.py
CHANGED
|
@@ -7,7 +7,6 @@ import shutil
|
|
|
7
7
|
import subprocess
|
|
8
8
|
import sys
|
|
9
9
|
import uuid
|
|
10
|
-
from enum import Enum
|
|
11
10
|
from functools import lru_cache
|
|
12
11
|
from pathlib import Path
|
|
13
12
|
from typing import Any
|
|
@@ -17,7 +16,7 @@ import structlog
|
|
|
17
16
|
from structlog.types import EventDict
|
|
18
17
|
|
|
19
18
|
from kodit import _version
|
|
20
|
-
from kodit.config import AppContext
|
|
19
|
+
from kodit.config import AppContext, LogFormat
|
|
21
20
|
|
|
22
21
|
_MAC_RE = re.compile(r"(?:[0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}")
|
|
23
22
|
|
|
@@ -35,13 +34,6 @@ def drop_color_message_key(_, __, event_dict: EventDict) -> EventDict: # noqa:
|
|
|
35
34
|
return event_dict
|
|
36
35
|
|
|
37
36
|
|
|
38
|
-
class LogFormat(Enum):
|
|
39
|
-
"""The format of the log output."""
|
|
40
|
-
|
|
41
|
-
PRETTY = "pretty"
|
|
42
|
-
JSON = "json"
|
|
43
|
-
|
|
44
|
-
|
|
45
37
|
def configure_logging(app_context: AppContext) -> None:
|
|
46
38
|
"""Configure logging for the application."""
|
|
47
39
|
timestamper = structlog.processors.TimeStamper(fmt="iso")
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
kodit/.gitignore,sha256=ztkjgRwL9Uud1OEi36hGQeDGk3OLK1NfDEO8YqGYy8o,11
|
|
2
2
|
kodit/__init__.py,sha256=aEKHYninUq1yh6jaNfvJBYg-6fenpN132nJt1UU6Jxs,59
|
|
3
|
-
kodit/_version.py,sha256=
|
|
4
|
-
kodit/app.py,sha256=
|
|
3
|
+
kodit/_version.py,sha256=dAYECGus8vEags4_X66QYJmiBFCY-yJJXDyexsFv72w,513
|
|
4
|
+
kodit/app.py,sha256=aK6TP-7L3aHCiatNm_SYSw0zU4G3EuOcvdBZ3xPHO_U,3917
|
|
5
5
|
kodit/cli.py,sha256=ZOS_VzCHGjJRZzZpaVR00QXSPIwRXPYu-pTrbEtlyR0,19328
|
|
6
|
-
kodit/config.py,sha256=
|
|
6
|
+
kodit/config.py,sha256=kuGdl-q5r9b7spt89-1mfVNuoQLqkXQ9-nuJFfRflUU,8940
|
|
7
7
|
kodit/database.py,sha256=kI9yBm4uunsgV4-QeVoCBL0wLzU4kYmYv5qZilGnbPE,1740
|
|
8
|
-
kodit/log.py,sha256=
|
|
8
|
+
kodit/log.py,sha256=XyuseZk90gUBj1B7np2UO2EW9eE_ApayIpPRvI19KCE,8651
|
|
9
9
|
kodit/mcp.py,sha256=aEcPc8dQiZaR0AswCZZNxcm_rhhUZNsEBimYti0ibSI,7221
|
|
10
10
|
kodit/middleware.py,sha256=xBmC6keFeNsS0y8XUcIKzJzuefkE9bq2UhW1fR5cqxg,2770
|
|
11
11
|
kodit/reporting.py,sha256=icce1ZyiADsA_Qz-mSjgn2H4SSqKuGfLKnw-yrl9nsg,2722
|
|
@@ -50,19 +50,19 @@ kodit/infrastructure/cloning/metadata.py,sha256=GD2UnCC1oR82RD0SVUqk9CJOqzXPxhOA
|
|
|
50
50
|
kodit/infrastructure/cloning/git/__init__.py,sha256=20ePcp0qE6BuLsjsv4KYB1DzKhMIMsPXwEqIEZtjTJs,34
|
|
51
51
|
kodit/infrastructure/cloning/git/working_copy.py,sha256=qYcrR5qP1rhWZiYGMT1p-1Alavi_YvQLXx4MgIV7eXs,2611
|
|
52
52
|
kodit/infrastructure/embedding/__init__.py,sha256=F-8nLlWAerYJ0MOIA4tbXHLan8bW5rRR84vzxx6tRKI,39
|
|
53
|
-
kodit/infrastructure/embedding/embedding_factory.py,sha256=
|
|
53
|
+
kodit/infrastructure/embedding/embedding_factory.py,sha256=BsePuOAU4UmFP1hbn3WwZkY6dTG-oxlte0l7P_LsuuA,3745
|
|
54
54
|
kodit/infrastructure/embedding/local_vector_search_repository.py,sha256=ExweyNEL5cP-g3eDhGqZSih7zhdOrop2WdFPPJL-tB4,3505
|
|
55
55
|
kodit/infrastructure/embedding/vectorchord_vector_search_repository.py,sha256=PIoU0HsDlaoXDXnGjOR0LAkAcW4JiE3ymJy_SBhEopc,8030
|
|
56
56
|
kodit/infrastructure/embedding/embedding_providers/__init__.py,sha256=qeZ-oAIAxMl5QqebGtO1lq-tHjl_ucAwOXePklcwwGk,34
|
|
57
57
|
kodit/infrastructure/embedding/embedding_providers/batching.py,sha256=a8CL9PX2VLmbeg616fc_lQzfC4BWTVn32m4SEhXpHxc,3279
|
|
58
58
|
kodit/infrastructure/embedding/embedding_providers/hash_embedding_provider.py,sha256=V6OdCuWyQQOvo3OJGRi-gBKDApIcrELydFg7T696P5s,2257
|
|
59
59
|
kodit/infrastructure/embedding/embedding_providers/local_embedding_provider.py,sha256=9aLV1Zg4KMhYWlGRwgAUtswW4aIabNqbsipWhAn64RI,4133
|
|
60
|
-
kodit/infrastructure/embedding/embedding_providers/openai_embedding_provider.py,sha256=
|
|
60
|
+
kodit/infrastructure/embedding/embedding_providers/openai_embedding_provider.py,sha256=QfvdXXbWa-1DQriCzV-TmFm3XGqnVP_7PSQ6u6fKnuw,3973
|
|
61
61
|
kodit/infrastructure/enrichment/__init__.py,sha256=8acZKNzql8Fs0lceFu9U3KoUrOptRBtVIxr_Iw6lz3Y,40
|
|
62
|
-
kodit/infrastructure/enrichment/enrichment_factory.py,sha256=
|
|
62
|
+
kodit/infrastructure/enrichment/enrichment_factory.py,sha256=_JWkna3g8q8hzaPq1NRfZU9Y_sv99xcloM4BCJAWmHw,2039
|
|
63
63
|
kodit/infrastructure/enrichment/local_enrichment_provider.py,sha256=7Vlwu1jPJ5KNUn1a51M1P-laUd5YVFJA8EeH6KO-95k,3960
|
|
64
64
|
kodit/infrastructure/enrichment/null_enrichment_provider.py,sha256=DhZkJBnkvXg_XSAs-oKiFnKqYFPnmTl3ikdxrqeEfbc,713
|
|
65
|
-
kodit/infrastructure/enrichment/openai_enrichment_provider.py,sha256=
|
|
65
|
+
kodit/infrastructure/enrichment/openai_enrichment_provider.py,sha256=quu9GLGhxGk3ilrg5kPZdGiCTfuQ20JuwM3Grv6qaQE,3332
|
|
66
66
|
kodit/infrastructure/git/__init__.py,sha256=0iMosFzudj4_xNIMe2SRbV6l5bWqkjnUsZoFsoZFuM8,33
|
|
67
67
|
kodit/infrastructure/git/git_utils.py,sha256=KERwmhWDR4ooMQKS-nSPxjvdCzoWF9NS6nhdeXyzdtY,571
|
|
68
68
|
kodit/infrastructure/ignore/__init__.py,sha256=VzFv8XOzHmsu0MEGnWVSF6KsgqLBmvHlRqAkT1Xb1MY,36
|
|
@@ -95,8 +95,8 @@ kodit/migrations/versions/c3f5137d30f5_index_all_the_things.py,sha256=r7ukmJ_axX
|
|
|
95
95
|
kodit/utils/__init__.py,sha256=DPEB1i8evnLF4Ns3huuAYg-0pKBFKUFuiDzOKG9r-sw,33
|
|
96
96
|
kodit/utils/dump_openapi.py,sha256=29VdjHpNSaGAg7RjQw0meq1OLhljCx1ElgBlTC8xoF4,1247
|
|
97
97
|
kodit/utils/path_utils.py,sha256=thK6YGGNvQThdBaCYCCeCvS1L8x-lwl3AoGht2jnjGw,1645
|
|
98
|
-
kodit-0.3.
|
|
99
|
-
kodit-0.3.
|
|
100
|
-
kodit-0.3.
|
|
101
|
-
kodit-0.3.
|
|
102
|
-
kodit-0.3.
|
|
98
|
+
kodit-0.3.14.dist-info/METADATA,sha256=H9I5v4D4kVAJnF1-ofQZpxvMif86Vn-CNNWGvV9VI7M,7672
|
|
99
|
+
kodit-0.3.14.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
100
|
+
kodit-0.3.14.dist-info/entry_points.txt,sha256=hoTn-1aKyTItjnY91fnO-rV5uaWQLQ-Vi7V5et2IbHY,40
|
|
101
|
+
kodit-0.3.14.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
102
|
+
kodit-0.3.14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|