mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2025-03-16 07:02:22 +00:00
Merge branch 'master' of github.com:Mintplex-Labs/anything-llm
This commit is contained in:
commit
75592ba898
6 changed files with 111 additions and 9 deletions
|
@ -150,7 +150,7 @@ This monorepo consists of three main sections:
|
|||
|
||||
Mintplex Labs & the community maintain a number of deployment methods, scripts, and templates that you can use to run AnythingLLM locally. Refer to the table below to read how to deploy on your preferred environment or to automatically deploy.
|
||||
| Docker | AWS | GCP | Digital Ocean | Render.com |
|
||||
|----------------------------------------|----:|-----|---------------|------------|
|
||||
|----------------------------------------|----|-----|---------------|------------|
|
||||
| [![Deploy on Docker][docker-btn]][docker-deploy] | [![Deploy on AWS][aws-btn]][aws-deploy] | [![Deploy on GCP][gcp-btn]][gcp-deploy] | [![Deploy on DigitalOcean][do-btn]][do-deploy] | [![Deploy on Render.com][render-btn]][render-deploy] |
|
||||
|
||||
| Railway | RepoCloud | Elestio |
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const { Telemetry } = require("../../../models/telemetry");
|
||||
const { validApiKey } = require("../../../utils/middleware/validApiKey");
|
||||
const { handleFileUpload } = require("../../../utils/files/multer");
|
||||
const { handleAPIFileUpload } = require("../../../utils/files/multer");
|
||||
const {
|
||||
viewLocalFiles,
|
||||
findDocumentInDocuments,
|
||||
|
@ -23,7 +23,7 @@ function apiDocumentEndpoints(app) {
|
|||
|
||||
app.post(
|
||||
"/v1/document/upload",
|
||||
[validApiKey, handleFileUpload],
|
||||
[validApiKey, handleAPIFileUpload],
|
||||
async (request, response) => {
|
||||
/*
|
||||
#swagger.tags = ['Documents']
|
||||
|
|
|
@ -339,6 +339,12 @@ function apiWorkspaceEndpoints(app) {
|
|||
required: true,
|
||||
type: 'string'
|
||||
}
|
||||
#swagger.parameters['apiSessionId'] = {
|
||||
in: 'query',
|
||||
description: 'Optional apiSessionId to filter by',
|
||||
required: false,
|
||||
type: 'string'
|
||||
}
|
||||
#swagger.responses[200] = {
|
||||
content: {
|
||||
"application/json": {
|
||||
|
@ -370,6 +376,7 @@ function apiWorkspaceEndpoints(app) {
|
|||
*/
|
||||
try {
|
||||
const { slug } = request.params;
|
||||
const { apiSessionId = null } = request.query;
|
||||
const workspace = await Workspace.get({ slug });
|
||||
|
||||
if (!workspace) {
|
||||
|
@ -377,7 +384,12 @@ function apiWorkspaceEndpoints(app) {
|
|||
return;
|
||||
}
|
||||
|
||||
const history = await WorkspaceChats.forWorkspace(workspace.id);
|
||||
const history = apiSessionId
|
||||
? await WorkspaceChats.forWorkspaceByApiSessionId(
|
||||
workspace.id,
|
||||
apiSessionId
|
||||
)
|
||||
: await WorkspaceChats.forWorkspace(workspace.id);
|
||||
response.status(200).json({ history: convertToChatHistory(history) });
|
||||
} catch (e) {
|
||||
console.error(e.message, e);
|
||||
|
|
|
@ -55,6 +55,31 @@ const WorkspaceChats = {
|
|||
}
|
||||
},
|
||||
|
||||
forWorkspaceByApiSessionId: async function (
|
||||
workspaceId = null,
|
||||
apiSessionId = null,
|
||||
limit = null,
|
||||
orderBy = null
|
||||
) {
|
||||
if (!workspaceId || !apiSessionId) return [];
|
||||
try {
|
||||
const chats = await prisma.workspace_chats.findMany({
|
||||
where: {
|
||||
workspaceId,
|
||||
user_id: null,
|
||||
api_session_id: String(apiSessionId),
|
||||
thread_id: null,
|
||||
},
|
||||
...(limit !== null ? { take: limit } : {}),
|
||||
...(orderBy !== null ? { orderBy } : { orderBy: { id: "asc" } }),
|
||||
});
|
||||
return chats;
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
|
||||
forWorkspace: async function (
|
||||
workspaceId = null,
|
||||
limit = null,
|
||||
|
|
|
@ -1649,6 +1649,15 @@
|
|||
"type": "string"
|
||||
},
|
||||
"description": "Unique slug of workspace to find"
|
||||
},
|
||||
{
|
||||
"name": "apiSessionId",
|
||||
"in": "query",
|
||||
"description": "Optional apiSessionId to filter by",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
|
|
|
@ -3,7 +3,10 @@ const path = require("path");
|
|||
const fs = require("fs");
|
||||
const { v4 } = require("uuid");
|
||||
|
||||
// Handle File uploads for auto-uploading.
|
||||
/**
|
||||
* Handle File uploads for auto-uploading.
|
||||
* Mostly used for internal GUI/API uploads.
|
||||
*/
|
||||
const fileUploadStorage = multer.diskStorage({
|
||||
destination: function (_, __, cb) {
|
||||
const uploadOutput =
|
||||
|
@ -20,6 +23,23 @@ const fileUploadStorage = multer.diskStorage({
|
|||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Handle API file upload as documents - this does not manipulate the filename
|
||||
* at all for encoding/charset reasons.
|
||||
*/
|
||||
const fileAPIUploadStorage = multer.diskStorage({
|
||||
destination: function (_, __, cb) {
|
||||
const uploadOutput =
|
||||
process.env.NODE_ENV === "development"
|
||||
? path.resolve(__dirname, `../../../collector/hotdir`)
|
||||
: path.resolve(process.env.STORAGE_DIR, `../../collector/hotdir`);
|
||||
cb(null, uploadOutput);
|
||||
},
|
||||
filename: function (_, file, cb) {
|
||||
cb(null, file.originalname);
|
||||
},
|
||||
});
|
||||
|
||||
// Asset storage for logos
|
||||
const assetUploadStorage = multer.diskStorage({
|
||||
destination: function (_, __, cb) {
|
||||
|
@ -38,7 +58,9 @@ const assetUploadStorage = multer.diskStorage({
|
|||
},
|
||||
});
|
||||
|
||||
// Asset sub-storage manager for pfp icons.
|
||||
/**
|
||||
* Handle PFP file upload as logos
|
||||
*/
|
||||
const pfpUploadStorage = multer.diskStorage({
|
||||
destination: function (_, __, cb) {
|
||||
const uploadOutput =
|
||||
|
@ -55,7 +77,12 @@ const pfpUploadStorage = multer.diskStorage({
|
|||
},
|
||||
});
|
||||
|
||||
// Handle Generic file upload as documents
|
||||
/**
|
||||
* Handle Generic file upload as documents from the GUI
|
||||
* @param {Request} request
|
||||
* @param {Response} response
|
||||
* @param {NextFunction} next
|
||||
*/
|
||||
function handleFileUpload(request, response, next) {
|
||||
const upload = multer({ storage: fileUploadStorage }).single("file");
|
||||
upload(request, response, function (err) {
|
||||
|
@ -73,7 +100,33 @@ function handleFileUpload(request, response, next) {
|
|||
});
|
||||
}
|
||||
|
||||
// Handle logo asset uploads
|
||||
/**
|
||||
* Handle API file upload as documents - this does not manipulate the filename
|
||||
* at all for encoding/charset reasons.
|
||||
* @param {Request} request
|
||||
* @param {Response} response
|
||||
* @param {NextFunction} next
|
||||
*/
|
||||
function handleAPIFileUpload(request, response, next) {
|
||||
const upload = multer({ storage: fileAPIUploadStorage }).single("file");
|
||||
upload(request, response, function (err) {
|
||||
if (err) {
|
||||
response
|
||||
.status(500)
|
||||
.json({
|
||||
success: false,
|
||||
error: `Invalid file upload. ${err.message}`,
|
||||
})
|
||||
.end();
|
||||
return;
|
||||
}
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle logo asset uploads
|
||||
*/
|
||||
function handleAssetUpload(request, response, next) {
|
||||
const upload = multer({ storage: assetUploadStorage }).single("logo");
|
||||
upload(request, response, function (err) {
|
||||
|
@ -91,7 +144,9 @@ function handleAssetUpload(request, response, next) {
|
|||
});
|
||||
}
|
||||
|
||||
// Handle PFP file upload as logos
|
||||
/**
|
||||
* Handle PFP file upload as logos
|
||||
*/
|
||||
function handlePfpUpload(request, response, next) {
|
||||
const upload = multer({ storage: pfpUploadStorage }).single("file");
|
||||
upload(request, response, function (err) {
|
||||
|
@ -111,6 +166,7 @@ function handlePfpUpload(request, response, next) {
|
|||
|
||||
module.exports = {
|
||||
handleFileUpload,
|
||||
handleAPIFileUpload,
|
||||
handleAssetUpload,
|
||||
handlePfpUpload,
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue