Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

Reverted the usage-store (#380)

Tahier Hussain3f86e97724de
diff --git a/frontend/src/components/helpers/socket-messages/SocketMessages.js b/frontend/src/components/helpers/socket-messages/SocketMessages.js
index 57925db30..207120ef8 100644
--- a/frontend/src/components/helpers/socket-messages/SocketMessages.js
+++ b/frontend/src/components/helpers/socket-messages/SocketMessages.js
@@ -7,6 +7,7 @@ import { useSocketLogsStore } from "../../../store/socket-logs-store";
import { useSocketMessagesStore } from "../../../store/socket-messages-store";
import { useSocketCustomToolStore } from "../../../store/socket-custom-tool";
import { useSessionStore } from "../../../store/session-store";
+import { useUsageStore } from "../../../store/usage-store";
function SocketMessages() {
const [logId, setLogId] = useState("");
@@ -23,6 +24,7 @@ function SocketMessages() {
const socket = useContext(SocketContext);
const { setAlertDetails } = useAlertStore();
const handleException = useExceptionHandler();
+ const { setLLMTokenUsage } = useUsageStore();
useEffect(() => {
setLogId(sessionDetails?.logEventsId || "");
@@ -44,6 +46,11 @@ function SocketMessages() {
if (msg?.type === "LOG" && msg?.service === "prompt") {
updateCusToolMessages(msg);
}
+ if (msg?.type === "LOG" && msg?.service === "usage") {
+ const remainingTokens =
+ msg?.max_token_count_set - msg?.added_token_count;
+ setLLMTokenUsage(Math.max(remainingTokens, 0));
+ }
} catch (err) {
setAlertDetails(handleException(err, "Failed to process socket message"));
}
diff --git a/frontend/src/store/usage-store.js b/frontend/src/store/usage-store.js
new file mode 100644
index 000000000..1b97b3d8d
--- /dev/null
+++ b/frontend/src/store/usage-store.js
@@ -0,0 +1,10 @@
+import { create } from "zustand";
+
+const useUsageStore = create((setState) => ({
+ llmTokenUsage: null,
+ setLLMTokenUsage: (data) => {
+ setState({ llmTokenUsage: data });
+ },
+}));
+
+export { useUsageStore };