From eb52faefd55e902648a68583df4840122749ab08 Mon Sep 17 00:00:00 2001 From: Andrii Ieroshenko Date: Fri, 15 Dec 2023 09:26:48 -0800 Subject: [PATCH] remove additional .reply() arg, AgentMsg field, open stngs button --- .../jupyter-ai/jupyter_ai/chat_handlers/base.py | 10 ++-------- packages/jupyter-ai/jupyter_ai/models.py | 1 - .../jupyter-ai/src/components/chat-messages.tsx | 15 +-------------- packages/jupyter-ai/src/components/chat.tsx | 2 +- packages/jupyter-ai/src/handler.ts | 1 - 5 files changed, 4 insertions(+), 25 deletions(-) diff --git a/packages/jupyter-ai/jupyter_ai/chat_handlers/base.py b/packages/jupyter-ai/jupyter_ai/chat_handlers/base.py index b6925c1cf..f8088970a 100644 --- a/packages/jupyter-ai/jupyter_ai/chat_handlers/base.py +++ b/packages/jupyter-ai/jupyter_ai/chat_handlers/base.py @@ -125,7 +125,7 @@ def handle_api_key_exc(self, e: Exception, message: HumanChatMessage): if hasattr(self.config_manager, "lm_provider"): provider_name = getattr(self.config_manager.lm_provider, "name", "") response = f"Oops! There's a problem connecting to {provider_name}. Please update your {provider_name} API key in the chat settings." - self.reply(response, message, show_edit_settings=True) + self.reply(response, message) async def _default_handle_exc(self, e: Exception, message: HumanChatMessage): """ @@ -138,18 +138,12 @@ async def _default_handle_exc(self, e: Exception, message: HumanChatMessage): ) self.reply(response, message) - def reply( - self, - response: str, - human_msg: Optional[HumanChatMessage] = None, - show_edit_settings: Optional[bool] = None, - ): + def reply(self, response: str, human_msg: Optional[HumanChatMessage] = None): agent_msg = AgentChatMessage( id=uuid4().hex, time=time.time(), body=response, reply_to=human_msg.id if human_msg else "", - show_edit_settings=show_edit_settings, ) for handler in self._root_chat_handlers.values(): diff --git a/packages/jupyter-ai/jupyter_ai/models.py b/packages/jupyter-ai/jupyter_ai/models.py index 156e65f49..41509a74d 100644 --- a/packages/jupyter-ai/jupyter_ai/models.py +++ b/packages/jupyter-ai/jupyter_ai/models.py @@ -36,7 +36,6 @@ class AgentChatMessage(BaseModel): body: str # message ID of the HumanChatMessage it is replying to reply_to: str - show_edit_settings: Optional[bool] class HumanChatMessage(BaseModel): diff --git a/packages/jupyter-ai/src/components/chat-messages.tsx b/packages/jupyter-ai/src/components/chat-messages.tsx index cc91e242d..850d6a543 100644 --- a/packages/jupyter-ai/src/components/chat-messages.tsx +++ b/packages/jupyter-ai/src/components/chat-messages.tsx @@ -1,8 +1,7 @@ import React, { useState, useEffect } from 'react'; -import { Avatar, Box, Button, Typography } from '@mui/material'; +import { Avatar, Box, Typography } from '@mui/material'; import type { SxProps, Theme } from '@mui/material'; -import SettingsIcon from '@mui/icons-material/Settings'; import ReactMarkdown from 'react-markdown'; import remarkMath from 'remark-math'; import rehypeKatex from 'rehype-katex'; @@ -15,7 +14,6 @@ import { Jupyternaut } from '../icons'; type ChatMessagesProps = { messages: AiService.ChatMessage[]; - openSettingsView: () => void; }; type ChatMessageHeaderProps = { @@ -172,17 +170,6 @@ export function ChatMessages(props: ChatMessagesProps): JSX.Element { > {message.body} - {message.type === 'agent' && message.show_edit_settings && ( - - )} ))} diff --git a/packages/jupyter-ai/src/components/chat.tsx b/packages/jupyter-ai/src/components/chat.tsx index fa0fa340d..ded339c70 100644 --- a/packages/jupyter-ai/src/components/chat.tsx +++ b/packages/jupyter-ai/src/components/chat.tsx @@ -146,7 +146,7 @@ function ChatBody({ return ( <> - +