Skip to content

Commit

Permalink
image and document preview tool
Browse files Browse the repository at this point in the history
  • Loading branch information
nl0 committed Jul 10, 2024
1 parent 6da6414 commit 314af98
Show file tree
Hide file tree
Showing 6 changed files with 472 additions and 101 deletions.
27 changes: 15 additions & 12 deletions catalog/app/components/Assistant/Model/Content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import { JsonRecord } from 'utils/types'

// XXX: schema for en/decoding to/from aws bedrock types?

export type DocumentFormat =
| 'pdf'
| 'csv'
| 'doc'
| 'docx'
| 'xls'
| 'xlsx'
| 'html'
| 'txt'
| 'md'
export const DOCUMENT_FORMATS = [

Check warning on line 7 in catalog/app/components/Assistant/Model/Content.ts

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Assistant/Model/Content.ts#L7

Added line #L7 was not covered by tests
'pdf',
'csv',
'doc',
'docx',
'xls',
'xlsx',
'html',
'txt',
'md',
] as const
export type DocumentFormat = (typeof DOCUMENT_FORMATS)[number]

export interface DocumentBlock {
format: DocumentFormat
Expand All @@ -22,7 +24,8 @@ export interface DocumentBlock {
source: Buffer | Uint8Array | Blob | string
}

export type ImageFormat = 'png' | 'jpeg' | 'gif' | 'webp'
export const IMAGE_FORMATS = ['png', 'jpeg', 'gif', 'webp'] as const

Check warning on line 27 in catalog/app/components/Assistant/Model/Content.ts

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Assistant/Model/Content.ts#L27

Added line #L27 was not covered by tests
export type ImageFormat = (typeof IMAGE_FORMATS)[number]

export interface ImageBlock {
format: ImageFormat
Expand Down Expand Up @@ -63,7 +66,7 @@ export type ToolResultStatus = 'success' | 'error'
export interface ToolResultBlock {
toolUseId: string
content: ToolResultContentBlock[]
status?: ToolResultStatus
status: ToolResultStatus
}

export type ResponseMessageContentBlock = Eff.Data.TaggedEnum<{
Expand Down
13 changes: 13 additions & 0 deletions catalog/app/components/Assistant/Model/GlobalTools/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as Tool from '../Tool'

import { useStartSearch } from './search'
import { useGetObject } from './preview'

Check warning on line 4 in catalog/app/components/Assistant/Model/GlobalTools/index.ts

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Assistant/Model/GlobalTools/index.ts#L3-L4

Added lines #L3 - L4 were not covered by tests

export function useGlobalTools(): Tool.Collection {
return {

Check warning on line 7 in catalog/app/components/Assistant/Model/GlobalTools/index.ts

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Assistant/Model/GlobalTools/index.ts#L6-L7

Added lines #L6 - L7 were not covered by tests
catalog_global_startSearch: useStartSearch(),
catalog_global_getObject: useGetObject(),
}
}

export { useGlobalTools as use }

Check warning on line 13 in catalog/app/components/Assistant/Model/GlobalTools/index.ts

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Assistant/Model/GlobalTools/index.ts#L13

Added line #L13 was not covered by tests
Loading

0 comments on commit 314af98

Please sign in to comment.