[BugFix] fix file path prefix error
Browse files
.env.example
CHANGED
@@ -38,7 +38,7 @@ CHAT__SIMILARITY_THRESHOLD=0.7
|
|
38 |
CHAT__INTERFACE_TITLE='Code Repository Q&A Assistant'
|
39 |
CHAT__INTERFACE_DESCRIPTION="Ask questions about the codebase and I'll help you understand it!"
|
40 |
CHAT__MAX_LENGTH_PER_CHUNK=8000
|
41 |
-
CHAT__CODE_PATH_PREFIX=
|
42 |
|
43 |
# Embedding Configuration
|
44 |
# Settings for text embedding generation
|
|
|
38 |
CHAT__INTERFACE_TITLE='Code Repository Q&A Assistant'
|
39 |
CHAT__INTERFACE_DESCRIPTION="Ask questions about the codebase and I'll help you understand it!"
|
40 |
CHAT__MAX_LENGTH_PER_CHUNK=8000
|
41 |
+
CHAT__CODE_PATH_PREFIX=''
|
42 |
|
43 |
# Embedding Configuration
|
44 |
# Settings for text embedding generation
|
src/knowlang/chat_bot/chat_interface.py
CHANGED
@@ -55,7 +55,9 @@ class CodeQAChatInterface:
|
|
55 |
def _get_code_block(self, file_path: str, start_line: int, end_line: int) -> str:
|
56 |
"""Read the specified lines from a file and return as a code block"""
|
57 |
try:
|
58 |
-
full_path = self.codebase_dir / file_path
|
|
|
|
|
59 |
with open(full_path, 'r') as f:
|
60 |
lines = f.readlines()
|
61 |
code_lines = lines[start_line-1:end_line]
|
|
|
55 |
def _get_code_block(self, file_path: str, start_line: int, end_line: int) -> str:
|
56 |
"""Read the specified lines from a file and return as a code block"""
|
57 |
try:
|
58 |
+
full_path = self.codebase_dir / file_path[len(self.config.chat.code_path_prefix):]
|
59 |
+
|
60 |
+
print(f"Reading code block from {full_path}")
|
61 |
with open(full_path, 'r') as f:
|
62 |
lines = f.readlines()
|
63 |
code_lines = lines[start_line-1:end_line]
|
src/knowlang/configs/chat_config.py
CHANGED
@@ -30,7 +30,7 @@ class ChatConfig(BaseSettings):
|
|
30 |
description="Maximum number of characters per chunk"
|
31 |
)
|
32 |
code_path_prefix: str = Field(
|
33 |
-
default="
|
34 |
description="Prefix of code paths in the chat interface"
|
35 |
)
|
36 |
|
|
|
30 |
description="Maximum number of characters per chunk"
|
31 |
)
|
32 |
code_path_prefix: str = Field(
|
33 |
+
default="",
|
34 |
description="Prefix of code paths in the chat interface"
|
35 |
)
|
36 |
|