remove legacy cost estimate for embedding

This commit is contained in:
Timothy Carambat
2026-03-26 15:02:23 -07:00
parent d767c398c7
commit fb4dff618f
4 changed files with 484 additions and 82 deletions

View File

@@ -1,5 +1,4 @@
import PreLoader from "@/components/Preloader";
import { dollarFormat } from "@/utils/numbers";
import WorkspaceFileRow from "./WorkspaceFileRow";
import { memo, useEffect, useState } from "react";
import ModalWrapper from "@/components/ModalWrapper";
@@ -23,7 +22,6 @@ function WorkspaceDirectory({
fetchKeys,
hasChanges,
saveChanges,
embeddingCosts,
movedItems,
}) {
const { t } = useTranslation();
@@ -232,22 +230,7 @@ function WorkspaceDirectory({
</div>
</div>
{hasChanges && (
<div className="flex items-center justify-between py-6">
<div className="text-white/80">
<p className="text-sm font-semibold">
{embeddingCosts === 0
? ""
: `Estimated Cost: ${
embeddingCosts < 0.01
? `< $0.01`
: dollarFormat(embeddingCosts)
}`}
</p>
<p className="mt-2 text-xs italic" hidden={embeddingCosts === 0}>
{t("connectors.directory.costs")}
</p>
</div>
<div className="flex items-center justify-end py-6">
<button
onClick={(e) => handleSaveChanges(e)}
className="border border-slate-200 px-5 py-2.5 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800"

View File

@@ -6,16 +6,7 @@ import showToast from "../../../../utils/toast";
import Directory from "./Directory";
import WorkspaceDirectory from "./WorkspaceDirectory";
// OpenAI Cost per token
// ref: https://openai.com/pricing#:~:text=%C2%A0/%201K%20tokens-,Embedding%20models,-Build%20advanced%20search
const MODEL_COSTS = {
"text-embedding-ada-002": 0.0000001, // $0.0001 / 1K tokens
"text-embedding-3-small": 0.00000002, // $0.00002 / 1K tokens
"text-embedding-3-large": 0.00000013, // $0.00013 / 1K tokens
};
export default function DocumentSettings({ workspace, systemSettings }) {
export default function DocumentSettings({ workspace }) {
const [highlightWorkspace, setHighlightWorkspace] = useState(false);
const [availableDocs, setAvailableDocs] = useState([]);
const [loading, setLoading] = useState(true);
@@ -23,7 +14,6 @@ export default function DocumentSettings({ workspace, systemSettings }) {
const [selectedItems, setSelectedItems] = useState({});
const [hasChanges, setHasChanges] = useState(false);
const [movedItems, setMovedItems] = useState([]);
const [embeddingsCost, setEmbeddingsCost] = useState(0);
const [loadingMessage, setLoadingMessage] = useState("");
const availableDocsRef = useRef([]);
@@ -164,25 +154,6 @@ export default function DocumentSettings({ workspace, systemSettings }) {
}
}
let totalTokenCount = 0;
newMovedItems.forEach((item) => {
const { cached, token_count_estimate } = item;
if (!cached) {
totalTokenCount += token_count_estimate;
}
});
// Do not do cost estimation unless the embedding engine is OpenAi.
if (systemSettings?.EmbeddingEngine === "openai") {
const COST_PER_TOKEN =
MODEL_COSTS[
systemSettings?.EmbeddingModelPref || "text-embedding-ada-002"
];
const dollarAmount = (totalTokenCount / 1000) * COST_PER_TOKEN;
setEmbeddingsCost(dollarAmount);
}
setMovedItems([...movedItems, ...newMovedItems]);
let newAvailableDocs = JSON.parse(JSON.stringify(availableDocs));
@@ -252,7 +223,6 @@ export default function DocumentSettings({ workspace, systemSettings }) {
fetchKeys={fetchKeys}
hasChanges={hasChanges}
saveChanges={updateWorkspace}
embeddingCosts={embeddingsCost}
movedItems={movedItems}
/>
</div>

View File

@@ -102,7 +102,7 @@ const ManageWorkspace = ({ hideModal = noop, providedSlug = null }) => {
)}
{selectedTab === "documents" ? (
<DocumentSettings workspace={workspace} systemSettings={settings} />
<DocumentSettings workspace={workspace} />
) : (
<DataConnectors workspace={workspace} systemSettings={settings} />
)}

View File

@@ -7,7 +7,7 @@
},
"servers": [
{
"url": "/api"
"url": "http:///api/"
}
],
"paths": {
@@ -17,7 +17,15 @@
"Authentication"
],
"description": "Verify the attached Authentication header contains a valid API token.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Valid auth token was found.",
@@ -56,7 +64,15 @@
"Admin"
],
"description": "Check to see if the instance is in multi-user-mode first. Methods are disabled until multi user mode is enabled via the UI.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -95,7 +111,15 @@
"Admin"
],
"description": "Check to see if the instance is in multi-user-mode first. Methods are disabled until multi user mode is enabled via the UI.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -145,7 +169,15 @@
"Admin"
],
"description": "Create a new user with username and password. Methods are disabled until multi user mode is enabled via the UI.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -220,6 +252,13 @@
"type": "string"
},
"description": "id of the user in the database."
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -288,6 +327,13 @@
"type": "string"
},
"description": "id of the user in the database."
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -335,7 +381,15 @@
"Admin"
],
"description": "List all existing invitations to instance regardless of status. Methods are disabled until multi user mode is enabled via the UI.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -387,7 +441,15 @@
"Admin"
],
"description": "Create a new invite code for someone to use to register with instance. Methods are disabled until multi user mode is enabled via the UI.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -461,6 +523,13 @@
"type": "string"
},
"description": "id of the invite in the database."
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -517,6 +586,13 @@
"type": "string"
},
"description": "id of the workspace."
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -581,6 +657,13 @@
"type": "string"
},
"description": "id of the workspace in the database."
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -654,6 +737,13 @@
"type": "string"
},
"description": "slug of the workspace in the database"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -733,7 +823,15 @@
"Admin"
],
"description": "All chats in the system ordered by most recent. Methods are disabled until multi user mode is enabled via the UI.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -787,7 +885,15 @@
"Admin"
],
"description": "Update multi-user preferences for instance. Methods are disabled until multi user mode is enabled via the UI.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -844,7 +950,15 @@
"Documents"
],
"description": "Upload a new file to AnythingLLM to be parsed and prepared for embedding, with optional metadata.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -950,6 +1064,13 @@
},
"description": "Target folder path (defaults to 'custom-documents' if not provided)",
"example": "my-folder"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -1058,7 +1179,15 @@
"Documents"
],
"description": "Upload a valid URL for AnythingLLM to scrape and prepare for embedding. Optionally, specify a comma-separated list of workspace slugs to embed the document into post-upload.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -1145,7 +1274,15 @@
"Documents"
],
"description": "Upload a file by specifying its raw text content and metadata values without having to upload a file.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -1228,7 +1365,15 @@
"Documents"
],
"description": "List of all locally-stored documents in instance",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -1292,6 +1437,13 @@
"type": "string"
},
"description": "Name of the folder to retrieve documents from"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -1353,7 +1505,15 @@
"Documents"
],
"description": "Check available filetypes and MIMEs that can be uploaded.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -1415,7 +1575,15 @@
"Documents"
],
"description": "Get the known available metadata schema for when doing a raw-text upload and the acceptable type of value for each key.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -1471,6 +1639,13 @@
"type": "string"
},
"description": "Unique document name to find (name in /documents)"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -1530,7 +1705,15 @@
"Documents"
],
"description": "Create a new folder inside the documents storage directory.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -1587,7 +1770,15 @@
"Documents"
],
"description": "Remove a folder and all its contents from the documents storage directory.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -1647,7 +1838,15 @@
"Documents"
],
"description": "Move files within the documents storage directory.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -1709,7 +1908,15 @@
"Workspaces"
],
"description": "Create a new workspace",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -1782,7 +1989,15 @@
"Workspaces"
],
"description": "List all current workspaces",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -1845,6 +2060,13 @@
"type": "string"
},
"description": "Unique slug of workspace to find"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -1908,6 +2130,13 @@
"type": "string"
},
"description": "Unique slug of workspace to delete"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -1953,6 +2182,13 @@
"type": "string"
},
"description": "Unique slug of workspace to find"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -2034,6 +2270,13 @@
},
"description": "Unique slug of workspace to find"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
},
{
"name": "apiSessionId",
"in": "query",
@@ -2130,6 +2373,13 @@
"type": "string"
},
"description": "Unique slug of workspace to find"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -2212,6 +2462,13 @@
"type": "string"
},
"description": "Unique slug of workspace to find"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -2266,6 +2523,13 @@
"schema": {
"type": "string"
}
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -2356,6 +2620,13 @@
"schema": {
"type": "string"
}
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -2465,6 +2736,13 @@
"type": "string"
},
"description": "Unique slug of workspace to search in"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -2530,7 +2808,6 @@
"System Settings"
],
"description": "Dump all settings to file storage",
"parameters": [],
"responses": {
"200": {
"description": "OK"
@@ -2562,7 +2839,15 @@
"System Settings"
],
"description": "Get all current system settings that are defined.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -2610,7 +2895,15 @@
"System Settings"
],
"description": "Number of all vectors in connected vector database",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -2652,7 +2945,15 @@
"System Settings"
],
"description": "Update a system setting or preference.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -2710,6 +3011,13 @@
],
"description": "Export all of the chats from the system in a known format. Output depends on the type sent. Will be send with the correct header for the output.",
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
},
{
"name": "type",
"in": "query",
@@ -2768,7 +3076,15 @@
"System Settings"
],
"description": "Permanently remove documents from the system.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Documents removed successfully.",
@@ -2842,6 +3158,13 @@
"type": "string"
},
"description": "Unique slug of workspace"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -2926,6 +3249,13 @@
"type": "string"
},
"description": "Unique slug of thread"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -3008,6 +3338,13 @@
"type": "string"
},
"description": "Unique slug of thread"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -3062,6 +3399,13 @@
"type": "string"
},
"description": "Unique slug of thread"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -3141,6 +3485,13 @@
"type": "string"
},
"description": "Unique slug of thread"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -3236,6 +3587,13 @@
"type": "string"
},
"description": "Unique slug of thread"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -3336,7 +3694,15 @@
"User Management"
],
"description": "List all users",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -3401,6 +3767,13 @@
"type": "string"
},
"description": "The ID of the user to issue a temporary auth token for"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -3451,7 +3824,15 @@
"OpenAI Compatible Endpoints"
],
"description": "Get all available \"models\" which are workspaces you can use for chatting.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -3507,7 +3888,15 @@
"OpenAI Compatible Endpoints"
],
"description": "Execute a chat with a workspace with OpenAI compatibility. Supports streaming as well. Model must be a workspace slug from /models.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK"
@@ -3576,7 +3965,15 @@
"OpenAI Compatible Endpoints"
],
"description": "Get the embeddings of any arbitrary text string. This will use the embedder provider set in the system. Please ensure the token length of each string fits within the context of your embedder model.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK"
@@ -3623,7 +4020,15 @@
"OpenAI Compatible Endpoints"
],
"description": "List all the vector database collections connected to AnythingLLM. These are essentially workspaces but return their unique vector db identifier - this is the same as the workspace slug.",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -3675,7 +4080,15 @@
"Embed"
],
"description": "List all active embeds",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -3751,6 +4164,13 @@
"type": "string"
},
"description": "UUID of the embed"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -3830,6 +4250,13 @@
"type": "string"
},
"description": "UUID of the session"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -3883,7 +4310,15 @@
"Embed"
],
"description": "Create a new embed configuration",
"parameters": [],
"parameters": [
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
@@ -3979,6 +4414,13 @@
"type": "string"
},
"description": "UUID of the embed to update"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -4056,6 +4498,13 @@
"type": "string"
},
"description": "UUID of the embed to delete"
},
{
"name": "Authorization",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {