support for ingest
This commit is contained in:
parent
05cd115162
commit
643539b548
3 changed files with 41 additions and 24 deletions
|
|
@ -83,10 +83,14 @@ function KnowledgeSourcesPage() {
|
||||||
|
|
||||||
// Settings state
|
// Settings state
|
||||||
// Note: backend internal Langflow URL is not needed on the frontend
|
// 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",
|
"1098eea1-6649-4e1d-aed1-b77249fb8dd0",
|
||||||
);
|
);
|
||||||
|
const [ingestFlowId, setIngestFlowId] = useState<string>(
|
||||||
|
"5488df7c-b93f-4f87-a446-b67028bc0813",
|
||||||
|
);
|
||||||
const [langflowEditUrl, setLangflowEditUrl] = useState<string>("");
|
const [langflowEditUrl, setLangflowEditUrl] = useState<string>("");
|
||||||
|
const [langflowIngestEditUrl, setLangflowIngestEditUrl] = useState<string>("");
|
||||||
const [publicLangflowUrl, setPublicLangflowUrl] = useState<string>("");
|
const [publicLangflowUrl, setPublicLangflowUrl] = useState<string>("");
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -97,11 +101,17 @@ function KnowledgeSourcesPage() {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const settings = await response.json();
|
const settings = await response.json();
|
||||||
if (settings.flow_id) {
|
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) {
|
if (settings.langflow_edit_url) {
|
||||||
setLangflowEditUrl(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) {
|
if (settings.langflow_public_url) {
|
||||||
setPublicLangflowUrl(settings.langflow_public_url);
|
setPublicLangflowUrl(settings.langflow_public_url);
|
||||||
}
|
}
|
||||||
|
|
@ -383,7 +393,11 @@ function KnowledgeSourcesPage() {
|
||||||
}
|
}
|
||||||
}, [tasks, prevTasks]);
|
}, [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 =
|
const derivedFromWindow =
|
||||||
typeof window !== "undefined"
|
typeof window !== "undefined"
|
||||||
? `${window.location.protocol}//${window.location.hostname}:7860`
|
? `${window.location.protocol}//${window.location.hostname}:7860`
|
||||||
|
|
@ -394,37 +408,37 @@ function KnowledgeSourcesPage() {
|
||||||
"http://localhost:7860"
|
"http://localhost:7860"
|
||||||
).replace(/\/$/, "");
|
).replace(/\/$/, "");
|
||||||
const computed = targetFlowId ? `${base}/flow/${targetFlowId}` : base;
|
const computed = targetFlowId ? `${base}/flow/${targetFlowId}` : base;
|
||||||
const url = langflowEditUrl || computed;
|
|
||||||
|
const url = editUrl || computed;
|
||||||
|
|
||||||
window.open(url, "_blank");
|
window.open(url, "_blank");
|
||||||
closeDialog(); // Close immediately after opening Langflow
|
closeDialog(); // Close immediately after opening Langflow
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRestoreFlow = (closeDialog: () => void) => {
|
const handleRestoreRetrievalFlow = (closeDialog: () => void) => {
|
||||||
fetch(`/api/reset-flow/retrieval`, {
|
fetch(`/api/reset-flow/retrieval`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then(() => {
|
||||||
console.log(data);
|
|
||||||
closeDialog(); // Close after successful completion
|
closeDialog(); // Close after successful completion
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.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)
|
closeDialog(); // Close even on error (could show error toast instead)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRestoreAgentFlow = (closeDialog: () => void) => {
|
const handleRestoreIngestFlow = (closeDialog: () => void) => {
|
||||||
fetch(`/api/reset-flow/agent`, {
|
fetch(`/api/reset-flow/ingest`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then(() => {
|
||||||
console.log(data);
|
|
||||||
closeDialog(); // Close after successful completion
|
closeDialog(); // Close after successful completion
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.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)
|
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."
|
description="This restores defaults and discards all custom settings and overrides. This can't be undone."
|
||||||
confirmText="Restore"
|
confirmText="Restore"
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
onConfirm={handleRestoreFlow}
|
onConfirm={handleRestoreIngestFlow}
|
||||||
/>
|
/>
|
||||||
<ConfirmationDialog
|
<ConfirmationDialog
|
||||||
trigger={
|
trigger={
|
||||||
|
|
@ -479,7 +493,7 @@ function KnowledgeSourcesPage() {
|
||||||
title="Edit Ingest flow in Langflow"
|
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."
|
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"
|
confirmText="Proceed"
|
||||||
onConfirm={(closeDialog) => handleEditInLangflow(flowId, closeDialog)}
|
onConfirm={(closeDialog) => handleEditInLangflow("ingest", closeDialog)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -544,7 +558,7 @@ function KnowledgeSourcesPage() {
|
||||||
description="This restores defaults and discards all custom settings and overrides. This can't be undone."
|
description="This restores defaults and discards all custom settings and overrides. This can't be undone."
|
||||||
confirmText="Restore"
|
confirmText="Restore"
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
onConfirm={handleRestoreAgentFlow}
|
onConfirm={handleRestoreRetrievalFlow}
|
||||||
/>
|
/>
|
||||||
<ConfirmationDialog
|
<ConfirmationDialog
|
||||||
trigger={
|
trigger={
|
||||||
|
|
@ -575,7 +589,7 @@ function KnowledgeSourcesPage() {
|
||||||
title="Edit Agent flow in Langflow"
|
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."
|
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"
|
confirmText="Proceed"
|
||||||
onConfirm={(closeDialog) => handleEditInLangflow(flowId, closeDialog)}
|
onConfirm={(closeDialog) => handleEditInLangflow("chat", closeDialog)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -11,16 +11,16 @@ async def reset_flow_endpoint(
|
||||||
request: Request,
|
request: Request,
|
||||||
chat_service,
|
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
|
# Get flow type from path parameter
|
||||||
flow_type = request.path_params.get("flow_type")
|
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(
|
return JSONResponse(
|
||||||
{
|
{
|
||||||
"success": False,
|
"success": False,
|
||||||
"error": "Invalid flow type. Must be 'nudges' or 'retrieval'"
|
"error": "Invalid flow type. Must be 'nudges', 'retrieval', or 'ingest'"
|
||||||
},
|
},
|
||||||
status_code=400
|
status_code=400
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -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 json
|
||||||
import os
|
import os
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
@ -13,7 +13,7 @@ class FlowsService:
|
||||||
"""Reset a Langflow flow by uploading the corresponding JSON file
|
"""Reset a Langflow flow by uploading the corresponding JSON file
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
flow_type: Either 'nudges' or 'retrieval'
|
flow_type: Either 'nudges', 'retrieval', or 'ingest'
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict: Success/error response
|
dict: Success/error response
|
||||||
|
|
@ -27,9 +27,12 @@ class FlowsService:
|
||||||
flow_id = NUDGES_FLOW_ID
|
flow_id = NUDGES_FLOW_ID
|
||||||
elif flow_type == "retrieval":
|
elif flow_type == "retrieval":
|
||||||
flow_file = "flows/openrag_agent.json"
|
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:
|
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
|
# Load flow JSON file
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue