Spaces:
Sleeping
Sleeping
mixpanel analytics & config refactoring
Browse files- app.py +1 -1
- poetry.lock +19 -1
- pyproject.toml +2 -1
- src/know_lang_bot/__main__.py +1 -1
- src/know_lang_bot/chat_bot/__main__.py +1 -1
- src/know_lang_bot/chat_bot/chat_graph.py +1 -1
- src/know_lang_bot/chat_bot/chat_interface.py +66 -12
- src/know_lang_bot/chat_bot/feedback.py +43 -0
- src/know_lang_bot/chat_bot/gradio_demo.py +1 -1
- src/know_lang_bot/configs/chat_config.py +23 -0
- src/know_lang_bot/{config.py → configs/config.py} +3 -1
- src/know_lang_bot/evaluation/chatbot_evaluation.py +1 -1
- src/know_lang_bot/evaluation/embedding_evaluation.py +1 -1
- src/know_lang_bot/models/batch_request.py +1 -1
- src/know_lang_bot/models/embeddings.py +1 -1
- src/know_lang_bot/parser/base/parser.py +1 -1
- src/know_lang_bot/parser/base/provider.py +1 -1
- src/know_lang_bot/parser/factory.py +1 -1
- src/know_lang_bot/parser/providers/filesystem.py +1 -1
- src/know_lang_bot/parser/providers/git.py +1 -1
- src/know_lang_bot/summarizer/summarizer.py +1 -1
- src/know_lang_bot/utils/migration/openai_embedding_migrations.py +1 -1
- src/know_lang_bot/utils/migration/voyage_embedding_migraions.py +1 -1
- tests/conftest.py +1 -1
- tests/test_summarizer.py +1 -1
app.py
CHANGED
@@ -2,7 +2,7 @@ import requests
|
|
2 |
import zipfile
|
3 |
import io
|
4 |
from know_lang_bot.chat_bot.chat_interface import create_chatbot
|
5 |
-
from know_lang_bot.config import AppConfig
|
6 |
import tempfile
|
7 |
from rich.console import Console
|
8 |
|
|
|
2 |
import zipfile
|
3 |
import io
|
4 |
from know_lang_bot.chat_bot.chat_interface import create_chatbot
|
5 |
+
from know_lang_bot.configs.config import AppConfig
|
6 |
import tempfile
|
7 |
from rich.console import Console
|
8 |
|
poetry.lock
CHANGED
@@ -2157,6 +2157,24 @@ typing-inspect = ">=0.9.0"
|
|
2157 |
[package.extras]
|
2158 |
gcp = ["google-auth (>=2.27.0)", "requests (>=2.32.3)"]
|
2159 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2160 |
[[package]]
|
2161 |
name = "mmh3"
|
2162 |
version = "5.1.0"
|
@@ -5329,4 +5347,4 @@ type = ["pytest-mypy"]
|
|
5329 |
[metadata]
|
5330 |
lock-version = "2.1"
|
5331 |
python-versions = ">=3.10, <3.13"
|
5332 |
-
content-hash = "
|
|
|
2157 |
[package.extras]
|
2158 |
gcp = ["google-auth (>=2.27.0)", "requests (>=2.32.3)"]
|
2159 |
|
2160 |
+
[[package]]
|
2161 |
+
name = "mixpanel"
|
2162 |
+
version = "4.10.1"
|
2163 |
+
description = "Official Mixpanel library for Python"
|
2164 |
+
optional = false
|
2165 |
+
python-versions = ">=2.7, !=3.4.*"
|
2166 |
+
groups = ["main"]
|
2167 |
+
markers = "python_version <= \"3.11\" or python_version >= \"3.12\""
|
2168 |
+
files = [
|
2169 |
+
{file = "mixpanel-4.10.1-py2.py3-none-any.whl", hash = "sha256:a7a338b7197327e36356dbc1903086e7626db6d88367ccdd732b3f3c60d3b3ed"},
|
2170 |
+
{file = "mixpanel-4.10.1.tar.gz", hash = "sha256:29a6b5773dd34f05cf8e249f4e1d16e7b6280d6b58894551ce9a5aad7700a115"},
|
2171 |
+
]
|
2172 |
+
|
2173 |
+
[package.dependencies]
|
2174 |
+
requests = ">=2.4.2"
|
2175 |
+
six = ">=1.9.0"
|
2176 |
+
urllib3 = "*"
|
2177 |
+
|
2178 |
[[package]]
|
2179 |
name = "mmh3"
|
2180 |
version = "5.1.0"
|
|
|
5347 |
[metadata]
|
5348 |
lock-version = "2.1"
|
5349 |
python-versions = ">=3.10, <3.13"
|
5350 |
+
content-hash = "9018994b12de342028b9f7a761de0f77f618a3e7489bebf2756e684fac5c00dd"
|
pyproject.toml
CHANGED
@@ -20,7 +20,8 @@ dependencies = [
|
|
20 |
"chromadb (>=0.6.3,<0.7.0)",
|
21 |
"ollama (>=0.4.7,<0.5.0)",
|
22 |
"gradio (>=5.13.1,<6.0.0)",
|
23 |
-
"voyageai (>=0.3.2,<0.4.0)"
|
|
|
24 |
]
|
25 |
|
26 |
[tool.poetry]
|
|
|
20 |
"chromadb (>=0.6.3,<0.7.0)",
|
21 |
"ollama (>=0.4.7,<0.5.0)",
|
22 |
"gradio (>=5.13.1,<6.0.0)",
|
23 |
+
"voyageai (>=0.3.2,<0.4.0)",
|
24 |
+
"mixpanel (>=4.10.1,<5.0.0)"
|
25 |
]
|
26 |
|
27 |
[tool.poetry]
|
src/know_lang_bot/__main__.py
CHANGED
@@ -7,7 +7,7 @@ from rich.console import Console
|
|
7 |
from rich.table import Table
|
8 |
|
9 |
from know_lang_bot.core.types import CodeChunk
|
10 |
-
from know_lang_bot.config import AppConfig
|
11 |
from know_lang_bot.parser.factory import CodeParserFactory
|
12 |
from know_lang_bot.parser.providers.git import GitProvider
|
13 |
from know_lang_bot.parser.providers.filesystem import FilesystemProvider
|
|
|
7 |
from rich.table import Table
|
8 |
|
9 |
from know_lang_bot.core.types import CodeChunk
|
10 |
+
from know_lang_bot.configs.config import AppConfig
|
11 |
from know_lang_bot.parser.factory import CodeParserFactory
|
12 |
from know_lang_bot.parser.providers.git import GitProvider
|
13 |
from know_lang_bot.parser.providers.filesystem import FilesystemProvider
|
src/know_lang_bot/chat_bot/__main__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from know_lang_bot.config import AppConfig
|
2 |
from know_lang_bot.chat_bot.chat_graph import process_chat
|
3 |
import chromadb
|
4 |
import asyncio
|
|
|
1 |
+
from know_lang_bot.configs.config import AppConfig
|
2 |
from know_lang_bot.chat_bot.chat_graph import process_chat
|
3 |
import chromadb
|
4 |
import asyncio
|
src/know_lang_bot/chat_bot/chat_graph.py
CHANGED
@@ -5,7 +5,7 @@ from typing import AsyncGenerator, List, Dict, Any, Optional
|
|
5 |
import chromadb
|
6 |
from pydantic import BaseModel
|
7 |
from pydantic_graph import BaseNode, EndStep, Graph, GraphRunContext, End, HistoryStep
|
8 |
-
from know_lang_bot.config import AppConfig, RerankerConfig, EmbeddingConfig
|
9 |
from know_lang_bot.utils.fancy_log import FancyLogger
|
10 |
from pydantic_ai import Agent
|
11 |
import logfire
|
|
|
5 |
import chromadb
|
6 |
from pydantic import BaseModel
|
7 |
from pydantic_graph import BaseNode, EndStep, Graph, GraphRunContext, End, HistoryStep
|
8 |
+
from know_lang_bot.configs.config import AppConfig, RerankerConfig, EmbeddingConfig
|
9 |
from know_lang_bot.utils.fancy_log import FancyLogger
|
10 |
from pydantic_ai import Agent
|
11 |
import logfire
|
src/know_lang_bot/chat_bot/chat_interface.py
CHANGED
@@ -1,8 +1,10 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
-
from know_lang_bot.config import AppConfig
|
3 |
from know_lang_bot.utils.fancy_log import FancyLogger
|
4 |
from know_lang_bot.utils.rate_limiter import RateLimiter
|
5 |
from know_lang_bot.chat_bot.chat_graph import stream_chat_progress, ChatStatus
|
|
|
6 |
import chromadb
|
7 |
from typing import List, Dict, AsyncGenerator
|
8 |
from pathlib import Path
|
@@ -11,12 +13,54 @@ from gradio import ChatMessage
|
|
11 |
|
12 |
LOG = FancyLogger(__name__)
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
class CodeQAChatInterface:
|
15 |
def __init__(self, config: AppConfig):
|
16 |
self.config = config
|
17 |
self._init_chroma()
|
18 |
self.codebase_dir = Path(config.db.codebase_directory)
|
19 |
self.rate_limiter = RateLimiter()
|
|
|
20 |
|
21 |
def _init_chroma(self):
|
22 |
"""Initialize ChromaDB connection"""
|
@@ -41,20 +85,28 @@ class CodeQAChatInterface:
|
|
41 |
|
42 |
def _format_code_block(self, metadata: Dict) -> str:
|
43 |
"""Format a single code block with metadata"""
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
49 |
if not code:
|
50 |
return None
|
51 |
-
|
52 |
-
title = f"📄 {file_path} (lines {start_line}-{end_line})"
|
53 |
-
if metadata.get('name'):
|
54 |
-
title += f" - {metadata['type']}: {metadata['name']}"
|
55 |
-
|
56 |
|
57 |
-
return f"<details><summary>{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
async def stream_response(
|
60 |
self,
|
@@ -178,12 +230,14 @@ class CodeQAChatInterface:
|
|
178 |
clear = gr.ClearButton([msg, chatbot], scale=1)
|
179 |
|
180 |
async def respond(message: str, history: List[ChatMessage], request: gr.Request) -> AsyncGenerator[List[ChatMessage], None]:
|
|
|
181 |
async for updated_history in self.stream_response(message, history, request):
|
182 |
yield updated_history
|
183 |
|
184 |
# Set up event handlers
|
185 |
msg.submit(respond, [msg, chatbot], [chatbot])
|
186 |
submit.click(respond, [msg, chatbot], [chatbot])
|
|
|
187 |
|
188 |
return interface
|
189 |
|
|
|
1 |
+
from dataclasses import dataclass
|
2 |
import gradio as gr
|
3 |
+
from know_lang_bot.configs.config import AppConfig
|
4 |
from know_lang_bot.utils.fancy_log import FancyLogger
|
5 |
from know_lang_bot.utils.rate_limiter import RateLimiter
|
6 |
from know_lang_bot.chat_bot.chat_graph import stream_chat_progress, ChatStatus
|
7 |
+
from know_lang_bot.chat_bot.feedback import ChatAnalytics
|
8 |
import chromadb
|
9 |
from typing import List, Dict, AsyncGenerator
|
10 |
from pathlib import Path
|
|
|
13 |
|
14 |
LOG = FancyLogger(__name__)
|
15 |
|
16 |
+
@dataclass
|
17 |
+
class CodeContext:
|
18 |
+
file_path: str
|
19 |
+
start_line: int
|
20 |
+
end_line: int
|
21 |
+
|
22 |
+
def to_title(self) -> str:
|
23 |
+
"""Format code context as a title string"""
|
24 |
+
title = f"📄 {self.file_path} (lines {self.start_line}-{self.end_line})"
|
25 |
+
return title
|
26 |
+
|
27 |
+
@classmethod
|
28 |
+
def from_title(cls, title: str) -> "CodeContext":
|
29 |
+
"""Parse code context from a title string"""
|
30 |
+
try:
|
31 |
+
# Split on first emoji and space
|
32 |
+
parts = title.split("📄 ")[1].split(" ")
|
33 |
+
file_path = parts[0]
|
34 |
+
# Extract line numbers from parentheses
|
35 |
+
line_nums = parts[1].strip("()").split(" ")[1].split("-")
|
36 |
+
start_line = int(line_nums[0])
|
37 |
+
end_line = int(line_nums[1])
|
38 |
+
|
39 |
+
return cls(
|
40 |
+
file_path=file_path,
|
41 |
+
start_line=start_line,
|
42 |
+
end_line=end_line,
|
43 |
+
)
|
44 |
+
except Exception as e:
|
45 |
+
LOG.error(f"Error parsing code context from title: {e}")
|
46 |
+
return None
|
47 |
+
|
48 |
+
@classmethod
|
49 |
+
def from_metadata(cls, metadata: Dict) -> "CodeContext":
|
50 |
+
"""Create code context from metadata dictionary"""
|
51 |
+
return cls(
|
52 |
+
file_path=metadata['file_path'],
|
53 |
+
start_line=metadata['start_line'],
|
54 |
+
end_line=metadata['end_line'],
|
55 |
+
)
|
56 |
+
|
57 |
class CodeQAChatInterface:
|
58 |
def __init__(self, config: AppConfig):
|
59 |
self.config = config
|
60 |
self._init_chroma()
|
61 |
self.codebase_dir = Path(config.db.codebase_directory)
|
62 |
self.rate_limiter = RateLimiter()
|
63 |
+
self.chat_analytics = ChatAnalytics(config.chat_analytics)
|
64 |
|
65 |
def _init_chroma(self):
|
66 |
"""Initialize ChromaDB connection"""
|
|
|
85 |
|
86 |
def _format_code_block(self, metadata: Dict) -> str:
|
87 |
"""Format a single code block with metadata"""
|
88 |
+
context = CodeContext.from_metadata(metadata)
|
89 |
+
code = self._get_code_block(
|
90 |
+
context.file_path,
|
91 |
+
context.start_line,
|
92 |
+
context.end_line
|
93 |
+
)
|
94 |
if not code:
|
95 |
return None
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
+
return f"<details><summary>{context.to_title()}</summary>\n\n```python\n{code}\n```\n\n</details>"
|
98 |
+
|
99 |
+
def _handle_feedback(self, like_data: gr.LikeData, history: List[ChatMessage], request: gr.Request):
|
100 |
+
# Get the query and response pair
|
101 |
+
query = history[like_data.index - 1]["content"] # User question
|
102 |
+
|
103 |
+
# Track feedback
|
104 |
+
self.chat_analytics.track_feedback(
|
105 |
+
like=like_data.value, # True for thumbs up, False for thumbs down
|
106 |
+
query=query,
|
107 |
+
client_ip=request.request.client.host
|
108 |
+
)
|
109 |
+
|
110 |
|
111 |
async def stream_response(
|
112 |
self,
|
|
|
230 |
clear = gr.ClearButton([msg, chatbot], scale=1)
|
231 |
|
232 |
async def respond(message: str, history: List[ChatMessage], request: gr.Request) -> AsyncGenerator[List[ChatMessage], None]:
|
233 |
+
self.chat_analytics.track_query(message, request.request.client.host)
|
234 |
async for updated_history in self.stream_response(message, history, request):
|
235 |
yield updated_history
|
236 |
|
237 |
# Set up event handlers
|
238 |
msg.submit(respond, [msg, chatbot], [chatbot])
|
239 |
submit.click(respond, [msg, chatbot], [chatbot])
|
240 |
+
chatbot.like(self._handle_feedback, [chatbot])
|
241 |
|
242 |
return interface
|
243 |
|
src/know_lang_bot/chat_bot/feedback.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from mixpanel import Mixpanel
|
2 |
+
from datetime import datetime
|
3 |
+
from enum import Enum
|
4 |
+
from know_lang_bot.configs.chat_config import ChatbotAnalyticsConfig
|
5 |
+
|
6 |
+
class ChatFeedback(Enum):
|
7 |
+
POSITIVE = "positive"
|
8 |
+
NEGATIVE = "negative"
|
9 |
+
|
10 |
+
|
11 |
+
class ChatAnalytics:
|
12 |
+
def __init__(self, config: ChatbotAnalyticsConfig):
|
13 |
+
self.mp = Mixpanel(config.api_key)
|
14 |
+
|
15 |
+
def track_query(
|
16 |
+
self,
|
17 |
+
query: str,
|
18 |
+
client_ip: str
|
19 |
+
):
|
20 |
+
"""Track query event in Mixpanel"""
|
21 |
+
self.mp.track(
|
22 |
+
distinct_id=hash(client_ip), # Hash for privacy
|
23 |
+
event_name="chat_query",
|
24 |
+
properties={
|
25 |
+
"query": query,
|
26 |
+
}
|
27 |
+
)
|
28 |
+
|
29 |
+
def track_feedback(
|
30 |
+
self,
|
31 |
+
like: bool,
|
32 |
+
query: str,
|
33 |
+
client_ip: str
|
34 |
+
):
|
35 |
+
"""Track feedback event in Mixpanel"""
|
36 |
+
self.mp.track(
|
37 |
+
distinct_id=hash(client_ip), # Hash for privacy
|
38 |
+
event_name="chat_feedback",
|
39 |
+
properties={
|
40 |
+
"feedback": ChatFeedback.POSITIVE.value if like else ChatFeedback.NEGATIVE.value,
|
41 |
+
"query": query,
|
42 |
+
}
|
43 |
+
)
|
src/know_lang_bot/chat_bot/gradio_demo.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
from know_lang_bot.chat_bot.chat_interface import create_chatbot
|
2 |
-
from know_lang_bot.config import AppConfig
|
3 |
|
4 |
|
5 |
config = AppConfig()
|
|
|
1 |
from know_lang_bot.chat_bot.chat_interface import create_chatbot
|
2 |
+
from know_lang_bot.configs.config import AppConfig
|
3 |
|
4 |
|
5 |
config = AppConfig()
|
src/know_lang_bot/configs/chat_config.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pydantic import Field
|
2 |
+
from pydantic_settings import BaseSettings
|
3 |
+
from enum import Enum
|
4 |
+
|
5 |
+
|
6 |
+
class AnalyticsProvider(str, Enum):
|
7 |
+
MIXPANEL = "mixpanel"
|
8 |
+
|
9 |
+
|
10 |
+
class ChatbotAnalyticsConfig(BaseSettings):
|
11 |
+
enabled: bool = Field(
|
12 |
+
default=False,
|
13 |
+
description="Enable analytics tracking"
|
14 |
+
)
|
15 |
+
provider: AnalyticsProvider = Field(
|
16 |
+
default=AnalyticsProvider.MIXPANEL,
|
17 |
+
description="Analytics provider to use for tracking feedback"
|
18 |
+
)
|
19 |
+
|
20 |
+
api_key: str = Field(
|
21 |
+
default=None,
|
22 |
+
description="api key for feedback tracking"
|
23 |
+
)
|
src/know_lang_bot/{config.py → configs/config.py}
RENAMED
@@ -4,6 +4,7 @@ from pydantic import Field, field_validator, ValidationInfo
|
|
4 |
from pathlib import Path
|
5 |
import fnmatch
|
6 |
from know_lang_bot.core.types import ModelProvider
|
|
|
7 |
import os
|
8 |
|
9 |
def _validate_api_key(v: Optional[str], info: ValidationInfo) -> Optional[str]:
|
@@ -215,4 +216,5 @@ class AppConfig(BaseSettings):
|
|
215 |
db: DBConfig = Field(default_factory=DBConfig)
|
216 |
parser: ParserConfig = Field(default_factory=ParserConfig)
|
217 |
chat: ChatConfig = Field(default_factory=ChatConfig)
|
218 |
-
embedding: EmbeddingConfig = Field(default_factory=EmbeddingConfig)
|
|
|
|
4 |
from pathlib import Path
|
5 |
import fnmatch
|
6 |
from know_lang_bot.core.types import ModelProvider
|
7 |
+
from know_lang_bot.configs.chat_config import ChatbotAnalyticsConfig
|
8 |
import os
|
9 |
|
10 |
def _validate_api_key(v: Optional[str], info: ValidationInfo) -> Optional[str]:
|
|
|
216 |
db: DBConfig = Field(default_factory=DBConfig)
|
217 |
parser: ParserConfig = Field(default_factory=ParserConfig)
|
218 |
chat: ChatConfig = Field(default_factory=ChatConfig)
|
219 |
+
embedding: EmbeddingConfig = Field(default_factory=EmbeddingConfig)
|
220 |
+
chat_analytics: ChatbotAnalyticsConfig = Field(default_factory=ChatbotAnalyticsConfig)
|
src/know_lang_bot/evaluation/chatbot_evaluation.py
CHANGED
@@ -2,7 +2,7 @@ from typing import List
|
|
2 |
from enum import Enum
|
3 |
from pydantic import BaseModel, Field, computed_field
|
4 |
from pydantic_ai import Agent
|
5 |
-
from know_lang_bot.config import AppConfig
|
6 |
from know_lang_bot.utils.chunking_util import truncate_chunk
|
7 |
from know_lang_bot.utils.model_provider import create_pydantic_model
|
8 |
from know_lang_bot.chat_bot.chat_graph import ChatResult, process_chat
|
|
|
2 |
from enum import Enum
|
3 |
from pydantic import BaseModel, Field, computed_field
|
4 |
from pydantic_ai import Agent
|
5 |
+
from know_lang_bot.configs.config import AppConfig
|
6 |
from know_lang_bot.utils.chunking_util import truncate_chunk
|
7 |
from know_lang_bot.utils.model_provider import create_pydantic_model
|
8 |
from know_lang_bot.chat_bot.chat_graph import ChatResult, process_chat
|
src/know_lang_bot/evaluation/embedding_evaluation.py
CHANGED
@@ -7,7 +7,7 @@ import numpy as np
|
|
7 |
from pydantic import BaseModel
|
8 |
from dataclasses import dataclass
|
9 |
from know_lang_bot.chat_bot.chat_graph import ChatResult
|
10 |
-
from know_lang_bot.config import AppConfig, EmbeddingConfig
|
11 |
import json
|
12 |
from know_lang_bot.evaluation.chatbot_evaluation import EvalCase, TRANSFORMER_TEST_CASES
|
13 |
from know_lang_bot.models.embeddings import EmbeddingInputType, generate_embedding, EmbeddingVector
|
|
|
7 |
from pydantic import BaseModel
|
8 |
from dataclasses import dataclass
|
9 |
from know_lang_bot.chat_bot.chat_graph import ChatResult
|
10 |
+
from know_lang_bot.configs.config import AppConfig, EmbeddingConfig
|
11 |
import json
|
12 |
from know_lang_bot.evaluation.chatbot_evaluation import EvalCase, TRANSFORMER_TEST_CASES
|
13 |
from know_lang_bot.models.embeddings import EmbeddingInputType, generate_embedding, EmbeddingVector
|
src/know_lang_bot/models/batch_request.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
from typing import List
|
2 |
-
from know_lang_bot.config import ModelProvider, LLMConfig
|
3 |
from pydantic_ai.messages import ModelMessage
|
4 |
|
5 |
def _process_anthropic_batch(batched_input: List[List[ModelMessage]], config: LLMConfig) -> List[str]:
|
|
|
1 |
from typing import List
|
2 |
+
from know_lang_bot.configs.config import ModelProvider, LLMConfig
|
3 |
from pydantic_ai.messages import ModelMessage
|
4 |
|
5 |
def _process_anthropic_batch(batched_input: List[List[ModelMessage]], config: LLMConfig) -> List[str]:
|
src/know_lang_bot/models/embeddings.py
CHANGED
@@ -2,7 +2,7 @@ import ollama
|
|
2 |
import openai
|
3 |
import voyageai
|
4 |
import voyageai.client
|
5 |
-
from know_lang_bot.config import EmbeddingConfig, ModelProvider
|
6 |
from typing import Union, List, overload, Optional
|
7 |
from enum import Enum
|
8 |
|
|
|
2 |
import openai
|
3 |
import voyageai
|
4 |
import voyageai.client
|
5 |
+
from know_lang_bot.configs.config import EmbeddingConfig, ModelProvider
|
6 |
from typing import Union, List, overload, Optional
|
7 |
from enum import Enum
|
8 |
|
src/know_lang_bot/parser/base/parser.py
CHANGED
@@ -2,7 +2,7 @@ from abc import ABC, abstractmethod
|
|
2 |
from typing import List
|
3 |
from pathlib import Path
|
4 |
from know_lang_bot.core.types import CodeChunk
|
5 |
-
from know_lang_bot.config import AppConfig, LanguageConfig
|
6 |
from tree_sitter import Language, Parser
|
7 |
|
8 |
class LanguageParser(ABC):
|
|
|
2 |
from typing import List
|
3 |
from pathlib import Path
|
4 |
from know_lang_bot.core.types import CodeChunk
|
5 |
+
from know_lang_bot.configs.config import AppConfig, LanguageConfig
|
6 |
from tree_sitter import Language, Parser
|
7 |
|
8 |
class LanguageParser(ABC):
|
src/know_lang_bot/parser/base/provider.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
from abc import ABC, abstractmethod
|
2 |
from typing import Generator
|
3 |
from pathlib import Path
|
4 |
-
from know_lang_bot.config import AppConfig
|
5 |
|
6 |
class CodeProvider(ABC):
|
7 |
"""Abstract base class for code source providers"""
|
|
|
1 |
from abc import ABC, abstractmethod
|
2 |
from typing import Generator
|
3 |
from pathlib import Path
|
4 |
+
from know_lang_bot.configs.config import AppConfig
|
5 |
|
6 |
class CodeProvider(ABC):
|
7 |
"""Abstract base class for code source providers"""
|
src/know_lang_bot/parser/factory.py
CHANGED
@@ -3,7 +3,7 @@ from pathlib import Path
|
|
3 |
|
4 |
from know_lang_bot.parser.base.parser import LanguageParser
|
5 |
from know_lang_bot.parser.languages.python.parser import PythonParser
|
6 |
-
from know_lang_bot.config import AppConfig
|
7 |
|
8 |
class CodeParserFactory():
|
9 |
"""Concrete implementation of parser factory"""
|
|
|
3 |
|
4 |
from know_lang_bot.parser.base.parser import LanguageParser
|
5 |
from know_lang_bot.parser.languages.python.parser import PythonParser
|
6 |
+
from know_lang_bot.configs.config import AppConfig
|
7 |
|
8 |
class CodeParserFactory():
|
9 |
"""Concrete implementation of parser factory"""
|
src/know_lang_bot/parser/providers/filesystem.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
from pathlib import Path
|
2 |
from typing import Generator
|
3 |
-
from know_lang_bot.config import AppConfig
|
4 |
from know_lang_bot.parser.base.provider import CodeProvider
|
5 |
import os
|
6 |
|
|
|
1 |
from pathlib import Path
|
2 |
from typing import Generator
|
3 |
+
from know_lang_bot.configs.config import AppConfig
|
4 |
from know_lang_bot.parser.base.provider import CodeProvider
|
5 |
import os
|
6 |
|
src/know_lang_bot/parser/providers/git.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
from pathlib import Path
|
2 |
from typing import Generator
|
3 |
from git import Repo
|
4 |
-
from know_lang_bot.config import AppConfig
|
5 |
from know_lang_bot.parser.base.provider import CodeProvider
|
6 |
import os
|
7 |
|
|
|
1 |
from pathlib import Path
|
2 |
from typing import Generator
|
3 |
from git import Repo
|
4 |
+
from know_lang_bot.configs.config import AppConfig
|
5 |
from know_lang_bot.parser.base.provider import CodeProvider
|
6 |
import os
|
7 |
|
src/know_lang_bot/summarizer/summarizer.py
CHANGED
@@ -6,7 +6,7 @@ from pydantic import BaseModel, Field
|
|
6 |
from pprint import pformat
|
7 |
from rich.progress import Progress
|
8 |
|
9 |
-
from know_lang_bot.config import AppConfig
|
10 |
from know_lang_bot.core.types import CodeChunk, ModelProvider
|
11 |
from know_lang_bot.utils.fancy_log import FancyLogger
|
12 |
from know_lang_bot.utils.model_provider import create_pydantic_model
|
|
|
6 |
from pprint import pformat
|
7 |
from rich.progress import Progress
|
8 |
|
9 |
+
from know_lang_bot.configs.config import AppConfig
|
10 |
from know_lang_bot.core.types import CodeChunk, ModelProvider
|
11 |
from know_lang_bot.utils.fancy_log import FancyLogger
|
12 |
from know_lang_bot.utils.model_provider import create_pydantic_model
|
src/know_lang_bot/utils/migration/openai_embedding_migrations.py
CHANGED
@@ -8,7 +8,7 @@ from rich.console import Console
|
|
8 |
from typing import List, Dict, Optional
|
9 |
from openai import OpenAI
|
10 |
from datetime import datetime
|
11 |
-
from know_lang_bot.config import AppConfig
|
12 |
from know_lang_bot.utils.fancy_log import FancyLogger
|
13 |
from know_lang_bot.utils.chunking_util import truncate_chunk
|
14 |
|
|
|
8 |
from typing import List, Dict, Optional
|
9 |
from openai import OpenAI
|
10 |
from datetime import datetime
|
11 |
+
from know_lang_bot.configs.config import AppConfig
|
12 |
from know_lang_bot.utils.fancy_log import FancyLogger
|
13 |
from know_lang_bot.utils.chunking_util import truncate_chunk
|
14 |
|
src/know_lang_bot/utils/migration/voyage_embedding_migraions.py
CHANGED
@@ -5,7 +5,7 @@ from chromadb.errors import InvalidCollectionException
|
|
5 |
from rich.progress import Progress
|
6 |
from rich.console import Console
|
7 |
from typing import List
|
8 |
-
from know_lang_bot.config import AppConfig, EmbeddingConfig
|
9 |
from know_lang_bot.models.embeddings import generate_embedding, EmbeddingInputType
|
10 |
from know_lang_bot.utils.fancy_log import FancyLogger
|
11 |
|
|
|
5 |
from rich.progress import Progress
|
6 |
from rich.console import Console
|
7 |
from typing import List
|
8 |
+
from know_lang_bot.configs.config import AppConfig, EmbeddingConfig
|
9 |
from know_lang_bot.models.embeddings import generate_embedding, EmbeddingInputType
|
10 |
from know_lang_bot.utils.fancy_log import FancyLogger
|
11 |
|
tests/conftest.py
CHANGED
@@ -3,7 +3,7 @@ import tempfile
|
|
3 |
import git
|
4 |
from pathlib import Path
|
5 |
from typing import Dict
|
6 |
-
from know_lang_bot.config import AppConfig, ParserConfig, LanguageConfig
|
7 |
from know_lang_bot.parser.languages.python.parser import PythonParser
|
8 |
from tests.test_data.python_files import TEST_FILES
|
9 |
|
|
|
3 |
import git
|
4 |
from pathlib import Path
|
5 |
from typing import Dict
|
6 |
+
from know_lang_bot.configs.config import AppConfig, ParserConfig, LanguageConfig
|
7 |
from know_lang_bot.parser.languages.python.parser import PythonParser
|
8 |
from tests.test_data.python_files import TEST_FILES
|
9 |
|
tests/test_summarizer.py
CHANGED
@@ -4,7 +4,7 @@ from unittest.mock import Mock, patch, AsyncMock
|
|
4 |
from pathlib import Path
|
5 |
from know_lang_bot.summarizer.summarizer import CodeSummarizer
|
6 |
from know_lang_bot.core.types import CodeChunk, ChunkType
|
7 |
-
from know_lang_bot.config import AppConfig
|
8 |
|
9 |
@pytest.fixture
|
10 |
def config():
|
|
|
4 |
from pathlib import Path
|
5 |
from know_lang_bot.summarizer.summarizer import CodeSummarizer
|
6 |
from know_lang_bot.core.types import CodeChunk, ChunkType
|
7 |
+
from know_lang_bot.configs.config import AppConfig
|
8 |
|
9 |
@pytest.fixture
|
10 |
def config():
|