Adjusted nudges var name, added nudges flow link to settings

This commit is contained in:
Lucas Oliveira 2025-09-10 17:57:41 -03:00
parent ffaec28596
commit 6052e7c55d
8 changed files with 20 additions and 12 deletions

View file

@ -8,7 +8,7 @@ LANGFLOW_SECRET_KEY=
# flow ids for chat and ingestion flows
LANGFLOW_CHAT_FLOW_ID=1098eea1-6649-4e1d-aed1-b77249fb8dd0
LANGFLOW_INGEST_FLOW_ID=5488df7c-b93f-4f87-a446-b67028bc0813
NUDGES_FLOW_ID=ebc01d31-1976-46ce-a385-b0240327226c
LANGFLOW_NUDGES_FLOW_ID=ebc01d31-1976-46ce-a385-b0240327226c
# Set a strong admin password for OpenSearch; a bcrypt hash is generated at
# container startup from this value. Do not commit real secrets.

View file

@ -56,7 +56,7 @@ services:
- LANGFLOW_CHAT_FLOW_ID=${LANGFLOW_CHAT_FLOW_ID}
- LANGFLOW_INGEST_FLOW_ID=${LANGFLOW_INGEST_FLOW_ID}
- DISABLE_INGEST_WITH_LANGFLOW=${DISABLE_INGEST_WITH_LANGFLOW:-false}
- NUDGES_FLOW_ID=${NUDGES_FLOW_ID}
- LANGFLOW_NUDGES_FLOW_ID=${LANGFLOW_NUDGES_FLOW_ID}
- OPENSEARCH_PORT=9200
- OPENSEARCH_USERNAME=admin
- OPENSEARCH_PASSWORD=${OPENSEARCH_PASSWORD}

View file

@ -55,7 +55,7 @@ services:
- LANGFLOW_CHAT_FLOW_ID=${LANGFLOW_CHAT_FLOW_ID}
- LANGFLOW_INGEST_FLOW_ID=${LANGFLOW_INGEST_FLOW_ID}
- DISABLE_INGEST_WITH_LANGFLOW=${DISABLE_INGEST_WITH_LANGFLOW:-false}
- NUDGES_FLOW_ID=${NUDGES_FLOW_ID}
- LANGFLOW_NUDGES_FLOW_ID=${LANGFLOW_NUDGES_FLOW_ID}
- OPENSEARCH_PORT=9200
- OPENSEARCH_USERNAME=admin
- OPENSEARCH_PASSWORD=${OPENSEARCH_PASSWORD}

View file

@ -5,6 +5,7 @@ from config.settings import (
LANGFLOW_CHAT_FLOW_ID,
LANGFLOW_INGEST_FLOW_ID,
LANGFLOW_PUBLIC_URL,
LANGFLOW_NUDGES_FLOW_ID,
clients,
)
@ -20,6 +21,7 @@ async def get_settings(request, session_manager):
"langflow_url": LANGFLOW_URL,
"flow_id": LANGFLOW_CHAT_FLOW_ID,
"ingest_flow_id": LANGFLOW_INGEST_FLOW_ID,
"langflow_nudges_flow_id": LANGFLOW_NUDGES_FLOW_ID,
"langflow_public_url": LANGFLOW_PUBLIC_URL,
}
@ -34,6 +36,11 @@ async def get_settings(request, session_manager):
f"{LANGFLOW_PUBLIC_URL.rstrip('/')}/flow/{LANGFLOW_INGEST_FLOW_ID}"
)
if LANGFLOW_PUBLIC_URL and LANGFLOW_NUDGES_FLOW_ID:
settings["langflow_nudges_edit_url"] = (
f"{LANGFLOW_PUBLIC_URL.rstrip('/')}/flow/{LANGFLOW_NUDGES_FLOW_ID}"
)
# Fetch ingestion flow configuration to get actual component defaults
if LANGFLOW_INGEST_FLOW_ID:
try:

View file

@ -30,7 +30,7 @@ _legacy_flow_id = os.getenv("FLOW_ID")
LANGFLOW_CHAT_FLOW_ID = os.getenv("LANGFLOW_CHAT_FLOW_ID") or _legacy_flow_id
LANGFLOW_INGEST_FLOW_ID = os.getenv("LANGFLOW_INGEST_FLOW_ID")
NUDGES_FLOW_ID = os.getenv("NUDGES_FLOW_ID")
LANGFLOW_NUDGES_FLOW_ID = os.getenv("LANGFLOW_NUDGES_FLOW_ID")
if _legacy_flow_id and not os.getenv("LANGFLOW_CHAT_FLOW_ID"):
logger.warning("FLOW_ID is deprecated. Please use LANGFLOW_CHAT_FLOW_ID instead")

View file

@ -1,4 +1,4 @@
from config.settings import NUDGES_FLOW_ID, clients, LANGFLOW_URL
from config.settings import LANGFLOW_NUDGES_FLOW_ID, clients, LANGFLOW_URL
from agent import (
async_chat,
async_langflow,
@ -170,9 +170,9 @@ class ChatService:
):
"""Handle Langflow chat requests"""
if not LANGFLOW_URL or not NUDGES_FLOW_ID:
if not LANGFLOW_URL or not LANGFLOW_NUDGES_FLOW_ID:
raise ValueError(
"LANGFLOW_URL and NUDGES_FLOW_ID environment variables are required"
"LANGFLOW_URL and LANGFLOW_NUDGES_FLOW_ID environment variables are required"
)
# Prepare extra headers for JWT authentication
@ -207,7 +207,7 @@ class ChatService:
response_text, response_id = await async_langflow_chat(
langflow_client,
NUDGES_FLOW_ID,
LANGFLOW_NUDGES_FLOW_ID,
prompt,
user_id,
extra_headers=extra_headers,

View file

@ -1,4 +1,4 @@
from config.settings import NUDGES_FLOW_ID, LANGFLOW_URL, LANGFLOW_CHAT_FLOW_ID, LANGFLOW_INGEST_FLOW_ID, clients
from config.settings import LANGFLOW_NUDGES_FLOW_ID, LANGFLOW_URL, LANGFLOW_CHAT_FLOW_ID, LANGFLOW_INGEST_FLOW_ID, clients
import json
import os
from utils.logging_config import get_logger
@ -23,7 +23,7 @@ class FlowsService:
# Determine flow file and ID based on type
if flow_type == "nudges":
flow_file = "flows/openrag_nudges.json"
flow_id = NUDGES_FLOW_ID
flow_id = LANGFLOW_NUDGES_FLOW_ID
elif flow_type == "retrieval":
flow_file = "flows/openrag_agent.json"
flow_id = LANGFLOW_CHAT_FLOW_ID

View file

@ -33,6 +33,7 @@ class EnvConfig:
langflow_superuser_password: str = ""
langflow_chat_flow_id: str = "1098eea1-6649-4e1d-aed1-b77249fb8dd0"
langflow_ingest_flow_id: str = "5488df7c-b93f-4f87-a446-b67028bc0813"
langflow_nudges_flow_id: str = "ebc01d31-1976-46ce-a385-b0240327226c"
# OAuth settings
google_oauth_client_id: str = ""
@ -105,7 +106,7 @@ class EnvManager:
"LANGFLOW_SUPERUSER_PASSWORD": "langflow_superuser_password",
"LANGFLOW_CHAT_FLOW_ID": "langflow_chat_flow_id",
"LANGFLOW_INGEST_FLOW_ID": "langflow_ingest_flow_id",
"NUDGES_FLOW_ID": "nudges_flow_id",
"LANGFLOW_NUDGES_FLOW_ID": "langflow_nudges_flow_id",
"GOOGLE_OAUTH_CLIENT_ID": "google_oauth_client_id",
"GOOGLE_OAUTH_CLIENT_SECRET": "google_oauth_client_secret",
"MICROSOFT_GRAPH_OAUTH_CLIENT_ID": "microsoft_graph_oauth_client_id",
@ -246,7 +247,7 @@ class EnvManager:
f.write(
f"LANGFLOW_INGEST_FLOW_ID={self.config.langflow_ingest_flow_id}\n"
)
f.write(f"NUDGES_FLOW_ID={self.config.nudges_flow_id}\n")
f.write(f"LANGFLOW_NUDGES_FLOW_ID={self.config.langflow_nudges_flow_id}\n")
f.write(f"OPENSEARCH_PASSWORD={self.config.opensearch_password}\n")
f.write(f"OPENAI_API_KEY={self.config.openai_api_key}\n")
f.write(