Aller au contenu

Langflow - Constructeur visuel d'agent IA et RAG

Langflow - Constructeur visuel d’agent IA et RAG

Langflow est un constructeur visuel open-source basé sur Python pour les applications LLM. Vous assemblez des agents, des chaînes et des pipelines RAG en faisant glisser et en reliant des composants sur un canevas, les testez dans un aire de jeu en direct, puis exposez tout flux en tant qu’endpoint API ou MCP. Il est agnostique du modèle (OpenAI, Anthropic, modèles locaux via Ollama, etc.) et s’appuie sur l’écosystème LangChain.

Installation

MéthodeCommande
uv (recommandé)uv pip install langflow
pippip install langflow
Exécuter après installlangflow run (ou python -m langflow run)
uvx (pas d’install)uvx langflow run
Dockerdocker run -it --rm -p 7860:7860 langflowai/langflow:latest
Application de bureauTélécharger depuis le site officiel (macOS/Windows)

Nécessite Python 3.10–3.13. Après langflow run, ouvrez http://localhost:7860.

Exécution du serveur

CommandeDescription
langflow runDémarrer l’interface utilisateur + API sur 127.0.0.1:7860
langflow run --host 0.0.0.0 --port 7860Se lier à toutes les interfaces / port personnalisé
langflow run --env-file .envCharger les variables d’environnement depuis un fichier
langflow run --devMode développeur/hot-reload
langflow --helpRéférence CLI complète
langflow api-keyCréer une clé API pour l’accès programmatique
langflow migrationExécuter les migrations de base de données

Concepts clés

TermeSignification
FlowUn graphique de composants connectés = une application/pipeline
ComponentUn nœud (modèle, invite, retrieveur, outil, agent, I/O)
Port / EdgeConnexion typée d’entrée/sortie entre composants
PlaygroundPanneau chat/run intégré pour tester un flux interactivement
ProjectUn espace de travail regroupant plusieurs flux
Global VariablesSecrets stockés (clés API) réutilisables dans tous les flux

Blocs de construction

CatégorieExemples
Entrées/SortiesChat Input, Chat Output, Text Input
ModèlesOpenAI, Anthropic, Google, Ollama, Groq, HuggingFace
InvitesModèle d’invite, message système
Données / RAGChargeur de fichier, URL, Split Text, Vector Store (Chroma, Qdrant, Astra, pgvector), Embeddings
AgentsComposant Agent avec appel d’outil
OutilsRecherche web, Python REPL, requête API, outils MCP
LogiqueRouteur conditionnel, boucle, pass-through

Flux RAG typique

File / URL  →  Split Text  →  Embeddings  →  Vector Store (ingestion)
Chat Input  →  Vector Store (recherche)  →  Prompt  →  Model  →  Chat Output

Construisez-le sur le canevas, ouvrez l’Playground, posez une question, et Langflow exécute le graphique de bout en bout.

Utiliser les flux depuis du code

Chaque flux obtient une API auto-générée. Depuis l’interface utilisateur, cliquez sur API (ou Share → API access) pour copier un extrait :

import requests

url = "http://localhost:7860/api/v1/run/<FLOW_ID>"
payload = {"input_value": "What is in my docs?", "output_type": "chat", "input_type": "chat"}
headers = {"x-api-key": "<YOUR_API_KEY>", "Content-Type": "application/json"}

resp = requests.post(url, json=payload, headers=headers)
print(resp.json())
# Même appel avec curl
curl -X POST "http://localhost:7860/api/v1/run/<FLOW_ID>" \
  -H "x-api-key: <YOUR_API_KEY>" -H "Content-Type: application/json" \
  -d '{"input_value":"hello","output_type":"chat","input_type":"chat"}'

Intégration MCP

CapacitéComment
Exposer les flux en tant qu’outils MCPChaque Project livre un serveur MCP ; pointez un client MCP (Claude Desktop, Cursor) vers celui-ci
Consommer les outils MCP externesAjouter le composant MCP Tools et connecter une URL/commande de serveur

Environnement et config

VariableObjectif
LANGFLOW_HOST / LANGFLOW_PORTAdresse de liaison et port
LANGFLOW_DATABASE_URLUtiliser Postgres au lieu du SQLite par défaut
LANGFLOW_AUTO_LOGIN=falseExiger la connexion (multi-utilisateur)
LANGFLOW_SUPERUSER / LANGFLOW_SUPERUSER_PASSWORDSeed un compte administrateur
LANGFLOW_SECRET_KEYClé de chiffrement pour les identifiants stockés
OPENAI_API_KEY, ANTHROPIC_API_KEY, …Clés du fournisseur (ou définir comme Global Variables)

Import / Export

ActionComment
Exporter un fluxMenu Flow → Export.json
Importer un fluxNew → Import le .json
Contrôle de versionEngager le JSON de flux exporté dans votre repo

Flux de travail courants

# Faire fonctionner pour une équipe sur un serveur avec Postgres + auth
LANGFLOW_DATABASE_URL=postgresql://user:pass@db:5432/langflow \
LANGFLOW_AUTO_LOGIN=false \
langflow run --host 0.0.0.0 --port 7860

# Essai éphémère local, pas d'install
uvx langflow run

Langflow vs Dify vs n8n

AspectLangflowDifyn8n
FocusFlux et agents de style LangChainPlateforme d’app LLMOps (RAG, invites)Automation générale + noeuds IA
StyleCanevas visuelStudio d’app + workflowAutomation de workflow
EndpointsAPI + MCPAPI + applications chatWebhooks/automation
Meilleur pourPrototyper des graphiques d’agent/RAGLivrer les applications LLM avec opsColler à travers 500+ services

Ressources