gabykim commited on
Commit
d1597d8
·
1 Parent(s): d403664

show progress of the summarization

Browse files
src/know_lang_bot/__main__.py CHANGED
@@ -122,9 +122,8 @@ async def main():
122
  else:
123
  LOG.warning("No code chunks found")
124
 
125
- with console.status("[bold green]Summarizing chunks...") as status:
126
- summarizer = CodeSummarizer(config)
127
- await summarizer.process_chunks(total_chunks)
128
 
129
  except Exception as e:
130
  LOG.error(f"Error: {str(e)}")
 
122
  else:
123
  LOG.warning("No code chunks found")
124
 
125
+ summarizer = CodeSummarizer(config)
126
+ await summarizer.process_chunks(total_chunks)
 
127
 
128
  except Exception as e:
129
  LOG.error(f"Error: {str(e)}")
src/know_lang_bot/summarizer/summarizer.py CHANGED
@@ -4,11 +4,12 @@ from chromadb.errors import InvalidCollectionException
4
  from pydantic_ai import Agent
5
  from pydantic import BaseModel, Field
6
  import ollama
 
 
7
 
8
  from know_lang_bot.config import AppConfig
9
  from know_lang_bot.core.types import CodeChunk, ModelProvider
10
  from know_lang_bot.utils.fancy_log import FancyLogger
11
- from pprint import pformat
12
 
13
  LOG = FancyLogger(__name__)
14
 
@@ -129,5 +130,9 @@ Provide a clean, concise and focused summary. Don't include unnecessary nor gene
129
 
130
  async def process_chunks(self, chunks: List[CodeChunk]):
131
  """Process multiple chunks in parallel"""
132
- for chunk in chunks:
133
- await self.process_and_store_chunk(chunk)
 
 
 
 
 
4
  from pydantic_ai import Agent
5
  from pydantic import BaseModel, Field
6
  import ollama
7
+ from pprint import pformat
8
+ from rich.progress import Progress
9
 
10
  from know_lang_bot.config import AppConfig
11
  from know_lang_bot.core.types import CodeChunk, ModelProvider
12
  from know_lang_bot.utils.fancy_log import FancyLogger
 
13
 
14
  LOG = FancyLogger(__name__)
15
 
 
130
 
131
  async def process_chunks(self, chunks: List[CodeChunk]):
132
  """Process multiple chunks in parallel"""
133
+ with Progress() as progress:
134
+ task = progress.add_task("Summarizing chunks into vector database...", total=len(chunks))
135
+
136
+ for chunk in chunks:
137
+ await self.process_and_store_chunk(chunk)
138
+ progress.advance(task)