Skip to content

Commit

Permalink
v2.3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpreetbedi committed Jan 29, 2024
1 parent 741734b commit 4ee0982
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
14 changes: 13 additions & 1 deletion phi/assistant/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,19 @@ def generate_name(self) -> str:
"""Generate a name for the run using the first 6 messages of the chat history"""

_conv = "Conversation\n"
for message in self.memory.chat_history[:6]:
_messages_for_generating_name = []
try:
if self.memory.chat_history[0].role == "assistant":
_messages_for_generating_name = self.memory.chat_history[1:6]
else:
_messages_for_generating_name = self.memory.chat_history[:6]
except Exception as e:
logger.warning(f"Failed to generate name: {e}")
finally:
if len(_messages_for_generating_name) == 0:
_messages_for_generating_name = self.memory.llm_messages[-4:]

for message in _messages_for_generating_name:
_conv += f"{message.role.upper()}: {message.content}\n"

_conv += "\n\nConversation Name:"
Expand Down
13 changes: 12 additions & 1 deletion phi/docker/resource/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def build_image(self, docker_client: DockerApiClient) -> Optional[Any]:
last_build_log = None
build_log_output: List[Any] = []
build_step_progress: List[str] = []
build_log_to_show_on_error: List[str] = []
try:
_api_client: DockerClient = docker_client.api_client
build_stream = _api_client.api.build(
Expand Down Expand Up @@ -173,10 +174,20 @@ def build_image(self, docker_client: DockerApiClient) -> Optional[Any]:
if len(build_step_progress) > 10:
build_step_progress.pop(0)

build_log_to_show_on_error.append(stream)
if len(build_log_to_show_on_error) > 50:
build_log_to_show_on_error.pop(0)

if "error" in stream.lower():
print(stream)
live_log.stop()
logger.error(f"Image build failed: {self.get_image_str()}")

# Render error table
error_table = Table(show_edge=False, show_header=False, show_lines=False)
for line in build_log_to_show_on_error:
error_table.add_row(line, style="dim")
error_table.add_row(stream, style="bold red")
console.print(error_table)
return None
if build_log.get("aux", None) is not None:
logger.debug("build_log['aux'] :{}".format(build_log["aux"]))
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "phidata"
version = "2.3.7"
version = "2.3.8"
description = "Build AI Assistants using language models"
requires-python = ">=3.7"
readme = "README.md"
Expand Down

0 comments on commit 4ee0982

Please sign in to comment.