diff --git a/devchat/assistant.py b/devchat/assistant.py index 651365e3..df369dc1 100644 --- a/devchat/assistant.py +++ b/devchat/assistant.py @@ -110,7 +110,7 @@ def iterate_response(self) -> Iterator[str]: first_chunk = False yield self._prompt.formatted_header() yield delta - if not self._prompt.responses or len(self._prompt.responses) == 0: + if not self._prompt.responses: raise RuntimeError("No responses returned from the chat API") self._store.store_prompt(self._prompt) yield self._prompt.formatted_footer(0) + '\n' @@ -119,7 +119,7 @@ def iterate_response(self) -> Iterator[str]: else: response_str = self._chat.complete_response(self._prompt) self._prompt.set_response(response_str) - if not self._prompt.responses or len(self._prompt.responses) == 0: + if not self._prompt.responses: raise RuntimeError("No responses returned from the chat API") self._store.store_prompt(self._prompt) for index in range(len(self._prompt.responses)): diff --git a/devchat/store.py b/devchat/store.py index 22804a0c..ea382e5a 100644 --- a/devchat/store.py +++ b/devchat/store.py @@ -92,7 +92,7 @@ def _update_topics_table(self, prompt: Prompt): logger.warning("Topic %s not found in graph but added", topic['root']) if prompt.parent == topic['root'] or \ prompt.parent in nx.ancestors(self._graph, topic['root']): - topic['latest_time'] = prompt.timestamp + topic['latest_time'] = max(topic.get('latest_time', 0), prompt.timestamp) self._topics_table.update(topic, doc_ids=[topic.doc_id]) break else: