Skip to content

Commit

Permalink
Fix bug in logging formatted string
Browse files Browse the repository at this point in the history
  • Loading branch information
basicthinker committed May 22, 2023
1 parent 18dcf94 commit 134319b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions devchat/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def make_prompt(self, request: str,
for reference_hash in references:
prompt = self._store.get_prompt(reference_hash)
if not prompt:
logger.error("Reference prompt not found: {reference_hash}")
logger.error("Reference prompt not found: %s", reference_hash)
continue
self._prompt.references.append(reference_hash)
self._append_prompt(prompt)
Expand All @@ -71,7 +71,7 @@ def make_prompt(self, request: str,
while parent_hash:
parent_prompt = self._store.get_prompt(parent_hash)
if not parent_prompt:
logger.error("Parent prompt not found: {parent_hash}")
logger.error("Parent prompt not found: %s", parent_hash)
break
if not self._append_prompt(parent_prompt):
break
Expand Down
2 changes: 1 addition & 1 deletion devchat/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def formatted_response(self, index: int) -> str:

response = self.response.get(index, None)
if response is None or response.content is None:
logger.error("Response {index} is incomplete.")
logger.error("Response %d is incomplete for formatted response.", index)
return None

formatted_str += response.content.strip() + "\n\n"
Expand Down
13 changes: 10 additions & 3 deletions devchat/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ def store_prompt(self, prompt: Prompt):
# Add edges for parents and references
if prompt.parent:
if prompt.parent not in self._graph:
logger.warning("Parent {prompt.parent} not found in the store.")
logger.warning("Parent %s not found in the store.", prompt.parent)
else:
self._graph.add_edge(prompt.hash, prompt.parent)
for reference_hash in prompt.references:
if reference_hash not in self._graph:
logger.warning('Reference {reference_hash} not found in the store.')
logger.warning("Reference %s not found in the store.", reference_hash)
else:
self._graph.add_edge(prompt.hash, reference_hash)
nx.write_graphml(self._graph, self._graph_path)
Expand Down Expand Up @@ -117,4 +117,11 @@ def select_recent(self, start: int, end: int) -> List[Prompt]:
reverse=True)
if end > len(sorted_nodes):
end = len(sorted_nodes)
return [self.get_prompt(note[0]) for note in sorted_nodes[start:end]]
prompts = []
for node in sorted_nodes[start:end]:
prompt = self.get_prompt(node[0])
if not prompt:
logger.error("Selected prompt %s not found in the store.", node[0])
continue
prompts.append(prompt)
return prompts

0 comments on commit 134319b

Please sign in to comment.