mirror of
https://github.com/ArthurDanjou/artagents.git
synced 2026-01-23 16:40:27 +01:00
feat: add chat and file management APIs, implement chat loading and saving functionality
- Introduced new API endpoints for chat management including posting and retrieving chat messages. - Implemented file upload and deletion functionalities for chat and other files. - Added utility functions for streaming text and loading chat data. - Created TypeScript types for models and agents used in the application. - Configured TypeScript settings for server and project. - Added favicon and workspace configuration for pnpm.
This commit is contained in:
12
server/api/files/index.delete.ts
Normal file
12
server/api/files/index.delete.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { z } from 'zod'
|
||||
import { useValidatedBody } from 'h3-zod'
|
||||
|
||||
export default eventHandler(async (event) => {
|
||||
const { pathname } = await useValidatedBody(event, {
|
||||
pathname: z.string()
|
||||
})
|
||||
|
||||
await hubBlob().del(pathname)
|
||||
|
||||
return sendNoContent(event)
|
||||
})
|
||||
3
server/api/files/index.get.ts
Normal file
3
server/api/files/index.get.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export default defineEventHandler(() => {
|
||||
return hubBlob().list()
|
||||
})
|
||||
18
server/api/files/index.post.ts
Normal file
18
server/api/files/index.post.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export default eventHandler(async (event) => {
|
||||
const form = await readFormData(event)
|
||||
const file = form.get('file') as File
|
||||
|
||||
if (!file || !file.size) {
|
||||
throw createError({ statusCode: 400, message: 'No file provided' })
|
||||
}
|
||||
|
||||
ensureBlob(file, {
|
||||
maxSize: '1MB',
|
||||
types: ['image', 'pdf', 'application/pdf']
|
||||
})
|
||||
|
||||
return hubBlob().put(file.name, file, {
|
||||
addRandomSuffix: false,
|
||||
prefix: 'files'
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user