Spaces:
Sleeping
Sleeping
summarize and store in __main__.py
Browse files
src/know_lang_bot/__main__.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import argparse
|
|
|
2 |
import sys
|
3 |
from pathlib import Path
|
4 |
from typing import List, Optional
|
@@ -10,6 +11,7 @@ from know_lang_bot.config import AppConfig
|
|
10 |
from know_lang_bot.parser.factory import CodeParserFactory
|
11 |
from know_lang_bot.parser.providers.git import GitProvider
|
12 |
from know_lang_bot.parser.providers.filesystem import FilesystemProvider
|
|
|
13 |
from know_lang_bot.utils.fancy_log import FancyLogger
|
14 |
|
15 |
LOG = FancyLogger(__name__)
|
@@ -84,7 +86,7 @@ def display_results_json(chunks: List[CodeChunk]):
|
|
84 |
import json
|
85 |
print(json.dumps([chunk.model_dump() for chunk in chunks], indent=2))
|
86 |
|
87 |
-
def main():
|
88 |
args = parse_args()
|
89 |
|
90 |
# Setup logging
|
@@ -110,8 +112,8 @@ def main():
|
|
110 |
# Process files
|
111 |
total_chunks = []
|
112 |
with console.status("[bold green]Parsing files...") as status:
|
113 |
-
for file_path in provider.get_files():
|
114 |
-
status.update(f"[bold green]
|
115 |
|
116 |
parser = factory.get_parser(file_path)
|
117 |
if parser:
|
@@ -128,6 +130,10 @@ def main():
|
|
128 |
else:
|
129 |
LOG.warning("No code chunks found")
|
130 |
|
|
|
|
|
|
|
|
|
131 |
except Exception as e:
|
132 |
LOG.error(f"Error: {str(e)}")
|
133 |
if args.verbose:
|
@@ -136,4 +142,4 @@ def main():
|
|
136 |
sys.exit(1)
|
137 |
|
138 |
if __name__ == "__main__":
|
139 |
-
main()
|
|
|
1 |
import argparse
|
2 |
+
import asyncio
|
3 |
import sys
|
4 |
from pathlib import Path
|
5 |
from typing import List, Optional
|
|
|
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
|
14 |
+
from know_lang_bot.summarizer.summarizer import CodeSummarizer
|
15 |
from know_lang_bot.utils.fancy_log import FancyLogger
|
16 |
|
17 |
LOG = FancyLogger(__name__)
|
|
|
86 |
import json
|
87 |
print(json.dumps([chunk.model_dump() for chunk in chunks], indent=2))
|
88 |
|
89 |
+
async def main():
|
90 |
args = parse_args()
|
91 |
|
92 |
# Setup logging
|
|
|
112 |
# Process files
|
113 |
total_chunks = []
|
114 |
with console.status("[bold green]Parsing files...") as status:
|
115 |
+
for idx, file_path in enumerate(provider.get_files()):
|
116 |
+
status.update(f"[bold yellow] Processed {idx+1} files, [bold green]processing {file_path}...\n")
|
117 |
|
118 |
parser = factory.get_parser(file_path)
|
119 |
if parser:
|
|
|
130 |
else:
|
131 |
LOG.warning("No code chunks found")
|
132 |
|
133 |
+
with console.status("[bold green]Summarizing chunks...") as status:
|
134 |
+
summarizer = CodeSummarizer(config)
|
135 |
+
await summarizer.process_chunks(total_chunks)
|
136 |
+
|
137 |
except Exception as e:
|
138 |
LOG.error(f"Error: {str(e)}")
|
139 |
if args.verbose:
|
|
|
142 |
sys.exit(1)
|
143 |
|
144 |
if __name__ == "__main__":
|
145 |
+
asyncio.run(main())
|