Spaces:
Sleeping
Sleeping
wuyiqunLu
commited on
Commit
•
f665131
1
Parent(s):
f816d16
feat: support send video to vision agent (#33)
Browse filesTODO: generate thumbnail for video
https://github.com/landing-ai/vision-agent-ui/assets/132986242/8b202e6f-4069-422b-82a8-0253a90bab56
- components/chat/ChatMessage.tsx +5 -0
- lib/aws.ts +1 -1
- lib/hooks/useImageUpload.ts +1 -0
- lib/messageUtils.ts +10 -3
components/chat/ChatMessage.tsx
CHANGED
@@ -86,6 +86,11 @@ export function ChatMessage({ message, ...props }: ChatMessageProps) {
|
|
86 |
);
|
87 |
},
|
88 |
img(props) {
|
|
|
|
|
|
|
|
|
|
|
89 |
return (
|
90 |
<Tooltip>
|
91 |
<TooltipTrigger asChild>
|
|
|
86 |
);
|
87 |
},
|
88 |
img(props) {
|
89 |
+
if (props.src?.endsWith('.mp4')) {
|
90 |
+
return (
|
91 |
+
<video src={props.src} controls width={500} height={500} />
|
92 |
+
);
|
93 |
+
}
|
94 |
return (
|
95 |
<Tooltip>
|
96 |
<TooltipTrigger asChild>
|
lib/aws.ts
CHANGED
@@ -2,7 +2,7 @@ import { createPresignedPost } from '@aws-sdk/s3-presigned-post';
|
|
2 |
import { S3Client } from '@aws-sdk/client-s3';
|
3 |
import { fromEnv } from '@aws-sdk/credential-providers';
|
4 |
|
5 |
-
const FILE_SIZE_LIMIT =
|
6 |
|
7 |
const s3Client = new S3Client({
|
8 |
region: process.env.AWS_REGION,
|
|
|
2 |
import { S3Client } from '@aws-sdk/client-s3';
|
3 |
import { fromEnv } from '@aws-sdk/credential-providers';
|
4 |
|
5 |
+
const FILE_SIZE_LIMIT = 104857600; // 100MB
|
6 |
|
7 |
const s3Client = new S3Client({
|
8 |
region: process.env.AWS_REGION,
|
lib/hooks/useImageUpload.ts
CHANGED
@@ -8,6 +8,7 @@ const useImageUpload = (
|
|
8 |
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
9 |
accept: {
|
10 |
'image/*': ['.jpeg', '.png'],
|
|
|
11 |
},
|
12 |
multiple: false,
|
13 |
onDrop: onDrop
|
|
|
8 |
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
9 |
accept: {
|
10 |
'image/*': ['.jpeg', '.png'],
|
11 |
+
'video/mp4': ['.mp4', '.MP4'],
|
12 |
},
|
13 |
multiple: false,
|
14 |
onDrop: onDrop
|
lib/messageUtils.ts
CHANGED
@@ -19,12 +19,19 @@ export const generateAnswersImageMarkdown = (index: number, url: string) => {
|
|
19 |
};
|
20 |
|
21 |
export const generateInputImageMarkdown = (url: string, index = 0) => {
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
24 |
};
|
25 |
|
26 |
export const cleanInputMessage = (content: string) => {
|
27 |
-
return content
|
|
|
|
|
28 |
};
|
29 |
|
30 |
export const cleanAnswerMessage = (content: string) => {
|
|
|
19 |
};
|
20 |
|
21 |
export const generateInputImageMarkdown = (url: string, index = 0) => {
|
22 |
+
if (url.toLowerCase().endsWith('.mp4')) {
|
23 |
+
const prefix = 'input-video';
|
24 |
+
return `![${INPUT_PREFIX}-${index}](<${url}>)`;
|
25 |
+
} else {
|
26 |
+
const prefix = 'input';
|
27 |
+
return `![${INPUT_PREFIX}-${index}](<${url}>)`;
|
28 |
+
}
|
29 |
};
|
30 |
|
31 |
export const cleanInputMessage = (content: string) => {
|
32 |
+
return content
|
33 |
+
.replace(/!\[input-.*?\)/g, '')
|
34 |
+
.replace(/<video[^>]*>.*?<\/video>/g, '');
|
35 |
};
|
36 |
|
37 |
export const cleanAnswerMessage = (content: string) => {
|