Skip to content

Commit

Permalink
Merge pull request #1 from brichet/add_chat_model
Browse files Browse the repository at this point in the history
Add a model to the chat panel
  • Loading branch information
brichet authored Mar 15, 2024
2 parents 1e9de21 + 0cf32e6 commit 9cc64e2
Show file tree
Hide file tree
Showing 20 changed files with 472 additions and 581 deletions.
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

0 comments on commit 9cc64e2

Please sign in to comment.