Skip to content

Commit

Permalink
introduce Jupyternaut (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlqqq authored May 5, 2023
1 parent e672c8f commit 5ec8cab
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/jupyter-ai/jupyter_ai/actors/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from jupyter_ai_magics.providers import BaseProvider

SYSTEM_PROMPT = """
You are Jupyter AI, a conversational assistant living in JupyterLab to help users.
You are Jupyternaut, a conversational assistant living in JupyterLab to help users.
You are not a language model, but rather an application built on a foundation model from {provider_name} called {local_model_id}.
You are talkative and provides lots of specific details from its context.
You may use Markdown to format your response.
Expand Down
2 changes: 1 addition & 1 deletion packages/jupyter-ai/jupyter_ai/actors/learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def create(self):
embeddings = self.get_embeddings()
if not embeddings:
return
self.index = FAISS.from_texts(["Jupyter AI knows about your filesystem, to ask questions first use the /learn command."], embeddings)
self.index = FAISS.from_texts(["Jupyternaut knows about your filesystem, to ask questions first use the /learn command."], embeddings)
self.save()

def save(self):
Expand Down
2 changes: 1 addition & 1 deletion packages/jupyter-ai/schema/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-07/schema",
"title": "Generative AI",
"description": "JupyterLab generative artificial intelligence integration.",
"jupyter.lab.setting-icon": "jupyter-ai::psychology",
"jupyter.lab.setting-icon": "jupyter-ai::chat",
"jupyter.lab.setting-icon-label": "Jupyter AI Chat",
"jupyter.lab.toolbars": {
"Cell": [
Expand Down
24 changes: 18 additions & 6 deletions packages/jupyter-ai/src/components/chat-messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useState, useEffect } from 'react';

import { Avatar, Box, Typography } from '@mui/material';
import type { SxProps, Theme } from '@mui/material';
import PsychologyIcon from '@mui/icons-material/Psychology';
import { formatDistanceToNowStrict, fromUnixTime } from 'date-fns';
import ReactMarkdown from 'react-markdown';
import remarkMath from 'remark-math';
Expand All @@ -12,6 +11,7 @@ import 'katex/dist/katex.min.css';
import { ChatCodeView } from './chat-code-view';
import { AiService } from '../handler';
import { useCollaboratorsContext } from '../contexts/collaborators-context';
import { Jupyternaut } from '../icons';

type ChatMessagesProps = {
messages: AiService.ChatMessage[];
Expand Down Expand Up @@ -54,15 +54,15 @@ export function ChatMessageHeader(props: ChatMessageHeaderProps) {
} else {
avatar = (
<Avatar sx={{ ...sharedStyles, bgcolor: 'var(--jp-jupyter-icon-color)' }}>
<PsychologyIcon />
<Jupyternaut display="block" height="100%" width="100%" />
</Avatar>
);
}

const name =
props.message.type === 'human'
? props.message.client.display_name
: 'Jupyter AI';
: 'Jupyternaut';

return (
<Box
Expand All @@ -85,8 +85,16 @@ export function ChatMessageHeader(props: ChatMessageHeaderProps) {
alignItems: 'center'
}}
>
<Typography sx={{ fontWeight: 700, color: 'var(--jp-ui-font-color1)' }}>{name}</Typography>
<Typography sx={{ fontSize: '0.8em', color: 'var(--jp-ui-font-color2)', fontWeight: 300 }}>
<Typography sx={{ fontWeight: 700, color: 'var(--jp-ui-font-color1)' }}>
{name}
</Typography>
<Typography
sx={{
fontSize: '0.8em',
color: 'var(--jp-ui-font-color2)',
fontWeight: 300
}}
>
{props.timestamp}
</Typography>
</Box>
Expand Down Expand Up @@ -120,7 +128,11 @@ export function ChatMessages(props: ChatMessagesProps) {

return (
<Box
sx={{ '& > :not(:last-child)': { borderBottom: '1px solid var(--jp-border-color2)' } }}
sx={{
'& > :not(:last-child)': {
borderBottom: '1px solid var(--jp-border-color2)'
}
}}
>
{props.messages.map((message, i) => (
// extra div needed to ensure each bubble is on a new line
Expand Down
16 changes: 9 additions & 7 deletions packages/jupyter-ai/src/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

import { LabIcon } from '@jupyterlab/ui-components';

import psychologySvgStr from '../style/icons/psychology.svg';
import chatSvgStr from '../style/icons/chat.svg';

export const psychologyIcon = new LabIcon({
name: 'jupyter-ai::psychology',
svgstr: psychologySvgStr
});
import jupyternautSvg from '../style/icons/jupyternaut.svg';

export const chatIcon = new LabIcon({
name: 'jupyter-ai::chat',
svgstr: chatSvgStr
});
});

export const jupyternautIcon = new LabIcon({
name: 'jupyter-ai::jupyternaut',
svgstr: jupyternautSvg
});

export const Jupyternaut = jupyternautIcon.react;
15 changes: 15 additions & 0 deletions packages/jupyter-ai/style/icons/jupyternaut.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions packages/jupyter-ai/style/icons/psychology.svg

This file was deleted.

0 comments on commit 5ec8cab

Please sign in to comment.