support for ingest

This commit is contained in:
Mike Fortman 2025-09-09 11:12:48 -05:00
parent 05cd115162
commit 643539b548
3 changed files with 41 additions and 24 deletions

View file

@ -83,10 +83,14 @@ function KnowledgeSourcesPage() {
// Settings state
// Note: backend internal Langflow URL is not needed on the frontend
const [flowId, setFlowId] = useState<string>(
const [chatFlowId, setChatFlowId] = useState<string>(
"1098eea1-6649-4e1d-aed1-b77249fb8dd0",
);
const [ingestFlowId, setIngestFlowId] = useState<string>(
"5488df7c-b93f-4f87-a446-b67028bc0813",
);
const [langflowEditUrl, setLangflowEditUrl] = useState<string>("");
const [langflowIngestEditUrl, setLangflowIngestEditUrl] = useState<string>("");
const [publicLangflowUrl, setPublicLangflowUrl] = useState<string>("");
@ -97,11 +101,17 @@ function KnowledgeSourcesPage() {
if (response.ok) {
const settings = await response.json();
if (settings.flow_id) {
setFlowId(settings.flow_id);
setChatFlowId(settings.flow_id);
}
if (settings.ingest_flow_id) {
setIngestFlowId(settings.ingest_flow_id);
}
if (settings.langflow_edit_url) {
setLangflowEditUrl(settings.langflow_edit_url);
}
if (settings.langflow_ingest_edit_url) {
setLangflowIngestEditUrl(settings.langflow_ingest_edit_url);
}
if (settings.langflow_public_url) {
setPublicLangflowUrl(settings.langflow_public_url);
}
@ -383,7 +393,11 @@ function KnowledgeSourcesPage() {
}
}, [tasks, prevTasks]);
const handleEditInLangflow = (targetFlowId: string, closeDialog: () => void) => {
const handleEditInLangflow = (flowType: "chat" | "ingest", closeDialog: () => void) => {
// Select the appropriate flow ID and edit URL based on flow type
const targetFlowId = flowType === "ingest" ? ingestFlowId : chatFlowId;
const editUrl = flowType === "ingest" ? langflowIngestEditUrl : langflowEditUrl;
const derivedFromWindow =
typeof window !== "undefined"
? `${window.location.protocol}//${window.location.hostname}:7860`
@ -394,37 +408,37 @@ function KnowledgeSourcesPage() {
"http://localhost:7860"
).replace(/\/$/, "");
const computed = targetFlowId ? `${base}/flow/${targetFlowId}` : base;
const url = langflowEditUrl || computed;
const url = editUrl || computed;
window.open(url, "_blank");
closeDialog(); // Close immediately after opening Langflow
};
const handleRestoreFlow = (closeDialog: () => void) => {
const handleRestoreRetrievalFlow = (closeDialog: () => void) => {
fetch(`/api/reset-flow/retrieval`, {
method: "POST",
})
.then((response) => response.json())
.then((data) => {
console.log(data);
.then(() => {
closeDialog(); // Close after successful completion
})
.catch((error) => {
console.error("Error restoring flow:", error);
console.error("Error restoring retrieval flow:", error);
closeDialog(); // Close even on error (could show error toast instead)
});
};
const handleRestoreAgentFlow = (closeDialog: () => void) => {
fetch(`/api/reset-flow/agent`, {
const handleRestoreIngestFlow = (closeDialog: () => void) => {
fetch(`/api/reset-flow/ingest`, {
method: "POST",
})
.then((response) => response.json())
.then((data) => {
console.log(data);
.then(() => {
closeDialog(); // Close after successful completion
})
.catch((error) => {
console.error("Error restoring agent flow:", error);
console.error("Error restoring ingest flow:", error);
closeDialog(); // Close even on error (could show error toast instead)
});
};
@ -448,7 +462,7 @@ function KnowledgeSourcesPage() {
description="This restores defaults and discards all custom settings and overrides. This can't be undone."
confirmText="Restore"
variant="destructive"
onConfirm={handleRestoreFlow}
onConfirm={handleRestoreIngestFlow}
/>
<ConfirmationDialog
trigger={
@ -479,7 +493,7 @@ function KnowledgeSourcesPage() {
title="Edit Ingest flow in Langflow"
description="You're entering Langflow. You can edit the Ingest flow and other underlying flows. Manual changes to components, wiring, or I/O can break this experience."
confirmText="Proceed"
onConfirm={(closeDialog) => handleEditInLangflow(flowId, closeDialog)}
onConfirm={(closeDialog) => handleEditInLangflow("ingest", closeDialog)}
/>
</div>
</div>
@ -544,7 +558,7 @@ function KnowledgeSourcesPage() {
description="This restores defaults and discards all custom settings and overrides. This can't be undone."
confirmText="Restore"
variant="destructive"
onConfirm={handleRestoreAgentFlow}
onConfirm={handleRestoreRetrievalFlow}
/>
<ConfirmationDialog
trigger={
@ -575,7 +589,7 @@ function KnowledgeSourcesPage() {
title="Edit Agent flow in Langflow"
description="You're entering Langflow. You can edit the Agent flow and other underlying flows. Manual changes to components, wiring, or I/O can break this experience."
confirmText="Proceed"
onConfirm={(closeDialog) => handleEditInLangflow(flowId, closeDialog)}
onConfirm={(closeDialog) => handleEditInLangflow("chat", closeDialog)}
/>
</div>
</div>

View file

@ -11,16 +11,16 @@ async def reset_flow_endpoint(
request: Request,
chat_service,
):
"""Reset a Langflow flow by type (nudges or retrieval)"""
"""Reset a Langflow flow by type (nudges, retrieval, or ingest)"""
# Get flow type from path parameter
flow_type = request.path_params.get("flow_type")
if flow_type not in ["nudges", "retrieval"]:
if flow_type not in ["nudges", "retrieval", "ingest"]:
return JSONResponse(
{
"success": False,
"error": "Invalid flow type. Must be 'nudges' or 'retrieval'"
"error": "Invalid flow type. Must be 'nudges', 'retrieval', or 'ingest'"
},
status_code=400
)

View file

@ -1,4 +1,4 @@
from config.settings import NUDGES_FLOW_ID, LANGFLOW_URL, FLOW_ID
from config.settings import NUDGES_FLOW_ID, LANGFLOW_URL, LANGFLOW_CHAT_FLOW_ID, LANGFLOW_INGEST_FLOW_ID
import json
import os
import aiohttp
@ -13,7 +13,7 @@ class FlowsService:
"""Reset a Langflow flow by uploading the corresponding JSON file
Args:
flow_type: Either 'nudges' or 'retrieval'
flow_type: Either 'nudges', 'retrieval', or 'ingest'
Returns:
dict: Success/error response
@ -27,9 +27,12 @@ class FlowsService:
flow_id = NUDGES_FLOW_ID
elif flow_type == "retrieval":
flow_file = "flows/openrag_agent.json"
flow_id = FLOW_ID
flow_id = LANGFLOW_CHAT_FLOW_ID
elif flow_type == "ingest":
flow_file = "flows/ingestion_flow.json"
flow_id = LANGFLOW_INGEST_FLOW_ID
else:
raise ValueError("flow_type must be either 'nudges' or 'retrieval'")
raise ValueError("flow_type must be either 'nudges', 'retrieval', or 'ingest'")
# Load flow JSON file
try: