Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a model to the chat panel #1

Merged
merged 6 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions jupyter_chat/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,13 @@ async def on_message(self, message):
return

# message broadcast to chat clients
chat_message_id = str(uuid.uuid4())
if not chat_request.id:
chat_request.id = str(uuid.uuid4())

chat_message = ChatMessage(
id=chat_message_id,
id=chat_request.id,
time=time.time(),
body=chat_request.prompt,
body=chat_request.body,
sender=self.chat_client,
)

Expand Down
3 changes: 2 additions & 1 deletion jupyter_chat/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

# the type of message used to chat with the agent
class ChatRequest(BaseModel):
prompt: str
body: str
id: str


class ChatUser(BaseModel):
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@
"@jupyterlab/rendermime": "^4.0.5",
"@jupyterlab/services": "^7.0.5",
"@jupyterlab/ui-components": "^4.0.5",
"@mui/icons-material": "5.11.0",
"@lumino/coreutils": "^2.1.2",
"@lumino/disposable": "^2.1.2",
"@lumino/signaling": "^2.1.2",
"@mui/icons-material": "^5.11.0",
"@mui/material": "^5.11.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
63 changes: 0 additions & 63 deletions src/__tests__/chat-settings.spec.ts

This file was deleted.

26 changes: 17 additions & 9 deletions src/components/chat-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@ import {
} from '@mui/material';
import SendIcon from '@mui/icons-material/Send';

type ChatInputProps = {
value: string;
onChange: (newValue: string) => unknown;
onSend: () => unknown;
sendWithShiftEnter: boolean;
sx?: SxProps<Theme>;
};

export function ChatInput(props: ChatInputProps): JSX.Element {
export function ChatInput(props: ChatInput.IProps): JSX.Element {
function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {
if (
event.key === 'Enter' &&
Expand Down Expand Up @@ -77,3 +69,19 @@ export function ChatInput(props: ChatInputProps): JSX.Element {
</Box>
);
}

/**
* The chat input namespace.
*/
export namespace ChatInput {
/**
* The properties of the react element.
*/
export interface IProps {
value: string;
onChange: (newValue: string) => unknown;
onSend: () => unknown;
sendWithShiftEnter: boolean;
sx?: SxProps<Theme>;
}
}
6 changes: 3 additions & 3 deletions src/components/chat-messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import type { SxProps, Theme } from '@mui/material';
import React, { useState, useEffect } from 'react';

import { RendermimeMarkdown } from './rendermime-markdown';
import { ChatService } from '../services';
import { IChatMessage, IUser } from '../types';

type ChatMessagesProps = {
rmRegistry: IRenderMimeRegistry;
messages: ChatService.IChatMessage[];
messages: IChatMessage[];
};

export type ChatMessageHeaderProps = ChatService.IUser & {
export type ChatMessageHeaderProps = IUser & {
timestamp: string;
sx?: SxProps<Theme>;
};
Expand Down
158 changes: 0 additions & 158 deletions src/components/chat-settings.tsx

This file was deleted.

Loading
Loading