mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-24 04:19:48 +01:00
- 新增 Langflow provider 实现,支持流式响应 - 添加 Langflow 集成文档 - 支持自定义 base_url、tweaks 等配置 Closes #2984 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3 KiB
3 KiB
Langflow Integration Guide
Overview
Langflow is a visual flow-based LLM orchestration platform that allows you to design conversational AI flows through a UI and invoke them via API. This integration enables xiaozhi-esp32-server to use Langflow flows as the LLM provider.
Configuration
Required Fields
type: Must be set tolangflowapi_key: Your Langflow API keyflow_id: The ID of your Langflow flow
Optional Fields
base_url: Langflow API endpoint (default:https://api.langflow.astra.datastax.com)tweaks: Runtime flow parameter overrides (default:{})
Example Configuration
llm:
type: langflow
api_key: "your_langflow_api_key_here"
flow_id: "your_flow_id_here"
base_url: "https://api.langflow.astra.datastax.com"
tweaks: {}
Setup Steps
1. Create a Langflow Flow
- Sign up at Langflow or deploy your own instance
- Create a new flow in the Langflow UI
- Design your conversational flow with components
- Ensure your flow has a Chat Input and Chat Output component
- Save and deploy your flow
2. Get API Credentials
- Navigate to your Langflow settings
- Generate an API key
- Copy your flow ID from the flow URL or settings
3. Configure xiaozhi-esp32-server
Add the configuration to your config.yaml or data/.config.yaml:
LLM:
LangflowLLM:
type: langflow
api_key: "sk-..."
flow_id: "abc123..."
base_url: "https://api.langflow.astra.datastax.com"
4. Select Langflow as Provider
Update your module selection:
selected_module:
LLM: LangflowLLM
Advanced Usage
Using Tweaks
The tweaks parameter allows you to customize flow components at runtime without modifying the flow design:
llm:
type: langflow
api_key: "your_api_key"
flow_id: "your_flow_id"
tweaks:
ChatOpenAI-abc123:
temperature: 0.7
model_name: "gpt-4"
To find component IDs for tweaks:
- Open your flow in Langflow
- Click on a component
- Copy the component ID from the settings panel
Troubleshooting
Connection Issues
- Verify your API key is correct
- Check that the base_url is accessible from your server
- Ensure your flow_id exists and is deployed
No Response
- Check Langflow logs for errors
- Verify your flow has proper Chat Input/Output components
- Test the flow directly in Langflow UI first
Session Not Persisting
- The integration automatically handles session management
- Each device gets a unique session_id for conversation continuity
API Reference
The integration uses Langflow's Run API:
POST {base_url}/api/v1/run/{flow_id}
Headers:
x-api-key: {api_key}
Body:
{
"input_value": "user message",
"output_type": "chat",
"input_type": "chat",
"session_id": "unique_session_id",
"tweaks": {}
}
Limitations
- System prompts configured in
config.yamlare ignored (configure in Langflow flow instead) - Function calling is not currently supported
- Response streaming depends on Langflow flow configuration