Skip to content

Commit

Permalink
Merge branch 'master' into rename-fix-sha256
Browse files Browse the repository at this point in the history
  • Loading branch information
sir-sigurd authored Jun 24, 2024
2 parents 52e5586 + 4c02a80 commit 16eb02b
Show file tree
Hide file tree
Showing 295 changed files with 7,523 additions and 6,834 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/py-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,23 @@ jobs:
python-version-file: lambdas/${{ matrix.path }}/.python-version
- name: Install dependencies
run: |
# Due to behavior change in pip>=23.1 installing tifffile==0.15.1
# from thumbnail lambda fails whithout installed wheel.
# See https://github.com/pypa/pip/issues/8559.
python -m pip install wheel
if [ ${{ matrix.path }} == "thumbnail" ]
then
# Due to behavior change in pip>=23.1 installing tifffile==0.15.1
# from thumbnail lambda fails whithout installed wheel.
# See https://github.com/pypa/pip/issues/8559.
# HACK: Pre-install numpy v1 as a build dependency for tifffile to prevent it from using v2 and failing to build
python -m pip install wheel 'numpy<2'
fi
# XXX: something fishy is going on with this "if [ ] X then Y" syntax
if [ ${{ matrix.path }} == "shared" ]
python -m pip install -e lambdas/shared[tests]
then
python -m pip install -e lambdas/shared
python -m pip install -e lambdas/${{ matrix.path }}
fi
python -m pip install -r lambdas/${{ matrix.path }}/test-requirements.txt
# Try to simulate the lambda .zip file:
Expand Down
4 changes: 2 additions & 2 deletions api/python/quilt3/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
urlparse,
urlunparse,
)
from urllib.request import pathname2url, url2pathname
from urllib.request import url2pathname

import requests
# Third-Party
Expand Down Expand Up @@ -222,7 +222,7 @@ def __repr__(self):

def __str__(self):
if self.bucket is None:
return urlunparse(('file', '', pathname2url(self.path.replace('/', os.path.sep)), None, None, None))
return pathlib.PurePath(self.path).as_uri()
else:
if self.version_id is None:
params = {}
Expand Down
2 changes: 1 addition & 1 deletion catalog/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM amazonlinux:2023.4.20240528.0
FROM amazonlinux:2023.4.20240611.0
MAINTAINER Quilt Data, Inc. [email protected]

ENV LC_ALL=C.UTF-8
Expand Down
4 changes: 2 additions & 2 deletions catalog/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Sentry.init(cfg, history)
import 'sanitize.css'

// Import the rest of our modules
import { ExperimentsProvider } from 'components/Experiments'
import * as Intercom from 'components/Intercom'
import Placeholder from 'components/Placeholder'
import App from 'containers/App'
Expand All @@ -39,6 +38,7 @@ import * as APIConnector from 'utils/APIConnector'
import * as GraphQL from 'utils/GraphQL'
import { BucketCacheProvider } from 'utils/BucketCache'
import GlobalAPI from 'utils/GlobalAPI'
import WithGlobalDialogs from 'utils/GlobalDialogs'
import log from 'utils/Logging'
import * as NamedRoutes from 'utils/NamedRoutes'
import { PFSCookieManager } from 'utils/PFSCookieManager'
Expand Down Expand Up @@ -116,13 +116,13 @@ const render = () => {
vertical_padding: 59,
},
],
ExperimentsProvider,
[Tracking.Provider, { userSelector: Auth.selectors.username }],
AWS.Credentials.Provider,
AWS.Config.Provider,
AWS.Athena.Provider,
AWS.S3.Provider,
Notifications.WithNotifications,
WithGlobalDialogs,
Errors.ErrorBoundary,
BucketCacheProvider,
PFSCookieManager,
Expand Down
91 changes: 91 additions & 0 deletions catalog/app/components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import * as React from 'react'
import * as M from '@material-ui/core'
import * as Lab from '@material-ui/lab'

import Skeleton from 'components/Skeleton'
import type * as AWS from 'utils/AWS'

import History from './History'
import Input from './Input'

const useStyles = M.makeStyles((t) => ({
root: {
display: 'flex',
flexDirection: 'column',
flexGrow: 1,
overflow: 'hidden',
},
error: {
marginTop: t.spacing(2),
},
history: {
...t.typography.body1,
maxHeight: t.spacing(70),
overflowY: 'auto',
},
input: {
marginTop: t.spacing(2),
},
}))

const noMessages: AWS.Bedrock.Message[] = []

export function ChatSkeleton() {
const classes = useStyles()
return (
<div className={classes.root}>
<History loading messages={noMessages} />
<Skeleton className={classes.input} height="32px" />
</div>
)
}

const Submitting = Symbol('Submitting')

interface ChatProps {
initializing: boolean
history: AWS.Bedrock.History
onSubmit: (value: string) => Promise<void>
}

export default function Chat({ history, onSubmit, initializing }: ChatProps) {
const classes = useStyles()

const [value, setValue] = React.useState('')
const [state, setState] = React.useState<Error | typeof Submitting | null>(null)

const handleSubmit = React.useCallback(async () => {
if (state) return

setState(Submitting)
try {
await onSubmit(value)
setValue('')
} catch (e) {
setState(e instanceof Error ? e : new Error('Failed to submit message'))
}
setState(null)
}, [state, onSubmit, value])

return (
<div className={classes.root}>
<History
className={classes.history}
loading={state === Submitting || initializing}
messages={history.messages}
/>
{state instanceof Error && (
<Lab.Alert className={classes.error} severity="error">
{state.message}
</Lab.Alert>
)}
<Input
className={classes.input}
disabled={state === Submitting}
onChange={setValue}
onSubmit={handleSubmit}
value={value}
/>
</div>
)
}
101 changes: 101 additions & 0 deletions catalog/app/components/Chat/History.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import cx from 'classnames'
import * as React from 'react'
import * as M from '@material-ui/core'

import usePrevious from 'utils/usePrevious'
import * as AWS from 'utils/AWS'

import * as Messages from './Message'

const useStyles = M.makeStyles((t) => ({
assistant: {
animation: `$show 300ms ease-out`,
},
message: {
'& + &': {
marginTop: t.spacing(2),
},
},
user: {
animation: `$slide 150ms ease-out`,
marginLeft: 'auto',
width: '60%',
},
'@keyframes slide': {
'0%': {
transform: `translateX($${t.spacing(8)}px)`,
},
'100%': {
transform: `translateX(0)`,
},
},
'@keyframes show': {
'0%': {
opacity: 0.7,
},
'100%': {
opacity: '1',
},
},
}))

interface HistoryProps {
className?: string
loading: boolean
messages: AWS.Bedrock.Message[]
}

export default function History({ className, loading, messages }: HistoryProps) {
const classes = useStyles()

const list = React.useMemo(
() => messages.filter((message) => message.role !== 'system'),
[messages],
)

const ref = React.useRef<HTMLDivElement | null>(null)
usePrevious(messages, (prev) => {
if (prev && messages.length > prev.length) {
ref.current?.scroll({
top: ref.current?.firstElementChild?.clientHeight,
behavior: 'smooth',
})
}
})

return (
<div className={className} ref={ref}>
<div /* full height scroll area */>
{list.map((message, index) => {
switch (message.role) {
case 'user':
return (
<Messages.User
key={`message_${index}`}
className={cx(classes.message, classes.user)}
content={message.content}
/>
)
case 'summarize':
return (
<Messages.User
key={`message_${index}`}
className={cx(classes.message, classes.user)}
content="Summarize this document"
/>
)
case 'assistant':
return (
<Messages.Assistant
key={`message_${index}`}
className={cx(classes.message, classes.assistant)}
content={message.content}
/>
)
}
})}
{loading && <Messages.Skeleton className={classes.message} />}
</div>
</div>
)
}
52 changes: 52 additions & 0 deletions catalog/app/components/Chat/Input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import * as React from 'react'
import * as M from '@material-ui/core'

interface ChatInputProps {
className?: string
disabled?: boolean
onChange: (value: string) => void
onSubmit: () => void
value: string
}

export default function ChatInput({
className,
disabled,
onChange,
onSubmit,
value,
}: ChatInputProps) {
const handleSubmit = React.useCallback(
(event) => {
event.preventDefault()
if (!value || disabled) return
onSubmit()
},
[disabled, onSubmit, value],
)
return (
<form onSubmit={handleSubmit}>
<M.TextField
autoFocus
className={className}
disabled={disabled}
fullWidth
helperText="Qurator may make errors. Verify critical information yourself."
label="Chat"
onChange={(e) => onChange(e.target.value)}
size="small"
value={value}
variant="outlined"
InputProps={{
endAdornment: (
<M.InputAdornment position="end">
<M.IconButton disabled={!value} onClick={onSubmit} type="submit">
<M.Icon>send</M.Icon>
</M.IconButton>
</M.InputAdornment>
),
}}
/>
</form>
)
}
Loading

0 comments on commit 16eb02b

Please sign in to comment.