Merge branch 'SessionManagment' of https://github.com/langflow-ai/langflow into SessionManagment

This commit is contained in:
cristhianzl 2024-06-03 18:17:19 -03:00
commit adeaf4db91
2 changed files with 20 additions and 3 deletions

View file

@ -1040,6 +1040,19 @@ export async function getMessagesTable(
return { rows: rows.data, columns };
}
export async function getSessions(id?: string): Promise<Array<string>> {
const config = {};
if (id) {
config["params"] = { flow_id: id };
}
const rows = await api.get(`${BASE_URL_API}monitor/messages`, config);
const sessions = new Set<string>();
rows.data.forEach((row) => {
sessions.add(row.session_id);
});
return Array.from(sessions);
}
export async function deleteMessagesFn(ids: number[]) {
try {
return await api.delete(`${BASE_URL_API}monitor/messages`, {

View file

@ -25,6 +25,7 @@ import { cn } from "../../utils/utils";
import BaseModal from "../baseModal";
import IOFieldView from "./components/IOFieldView";
import ChatView from "./components/chatView";
import { getSessions } from "../../controllers/API";
export default function IOModal({
children,
@ -78,6 +79,7 @@ export default function IOModal({
const isBuilding = useFlowStore((state) => state.isBuilding);
const currentFlow = useFlowsManagerStore((state) => state.currentFlow);
const setNode = useFlowStore((state) => state.setNode);
const [sessions, setSessions] = useState<string[]>([]);
async function updateVertices() {
return updateVerticesOrder(currentFlow!.id, null);
@ -113,9 +115,11 @@ export default function IOModal({
useEffect(() => {
setSelectedViewField(startView());
if (haveChat) {
//TODO: fetch avaliable Sessions
}
// if (haveChat) {
// getSessions().then((sessions) => {
// setSessions(sessions);
// });
// }
}, [open]);
return (