Skip to content

Commit

Permalink
remove additional .reply() arg, AgentMsg field, open stngs button
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-i committed Dec 19, 2023
1 parent 45260be commit 1684cf6
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 25 deletions.
10 changes: 2 additions & 8 deletions packages/jupyter-ai/jupyter_ai/chat_handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,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):
"""
Expand All @@ -168,18 +168,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():
Expand Down
1 change: 0 additions & 1 deletion packages/jupyter-ai/jupyter_ai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
15 changes: 1 addition & 14 deletions packages/jupyter-ai/src/components/chat-messages.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -15,7 +14,6 @@ import { Jupyternaut } from '../icons';

type ChatMessagesProps = {
messages: AiService.ChatMessage[];
openSettingsView: () => void;
};

type ChatMessageHeaderProps = {
Expand Down Expand Up @@ -172,17 +170,6 @@ export function ChatMessages(props: ChatMessagesProps): JSX.Element {
>
{message.body}
</ReactMarkdown>
{message.type === 'agent' && message.show_edit_settings && (
<Button
variant="contained"
startIcon={<SettingsIcon />}
size={'large'}
onClick={props.openSettingsView}
fullWidth
>
Open Settings
</Button>
)}
</Box>
))}
</Box>
Expand Down
2 changes: 1 addition & 1 deletion packages/jupyter-ai/src/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function ChatBody({
return (
<>
<ScrollContainer sx={{ flexGrow: 1 }}>
<ChatMessages messages={messages} openSettingsView={openSettingsView} />
<ChatMessages messages={messages} />
</ScrollContainer>
<ChatInput
value={input}
Expand Down
1 change: 0 additions & 1 deletion packages/jupyter-ai/src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export namespace AiService {
time: number;
body: string;
reply_to: string;
show_edit_settings?: boolean;
};

export type HumanChatMessage = {
Expand Down

0 comments on commit 1684cf6

Please sign in to comment.