feat: Chatbot-Workflows mit Ollama-Memory und Session-Management
- docker-compose: extra_hosts für host.docker.internal (Ollama-Zugang) - ollama-chatbot: Gesprächsverlauf per session_id in PostgreSQL - ollama-chat-cleanup: stündliche TTL-Bereinigung (2h Inaktivität) - ollama-chat-delete: DELETE /webhook/chat-session Endpoint Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
897b1ccf3d
commit
60143b8061
4 changed files with 246 additions and 0 deletions
53
imports/workflows/ollama-chat-cleanup.json
Normal file
53
imports/workflows/ollama-chat-cleanup.json
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"id": "1002",
|
||||
"name": "Chatbot Session Cleanup (TTL 2h)",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"rule": {
|
||||
"interval": [{ "field": "hours", "hoursInterval": 1 }]
|
||||
}
|
||||
},
|
||||
"id": "node-sc-001",
|
||||
"name": "Jede Stunde",
|
||||
"type": "n8n-nodes-base.scheduleTrigger",
|
||||
"typeVersion": 1.2,
|
||||
"position": [100, 300]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "executeQuery",
|
||||
"query": "DELETE FROM chat_sessions WHERE updated_at < NOW() - INTERVAL '2 hours' RETURNING session_id",
|
||||
"additionalFields": {}
|
||||
},
|
||||
"id": "node-pg-003",
|
||||
"name": "Delete Expired Sessions",
|
||||
"type": "n8n-nodes-base.postgres",
|
||||
"typeVersion": 2.5,
|
||||
"position": [300, 300],
|
||||
"credentials": {
|
||||
"postgres": {
|
||||
"id": "SETUP_REQUIRED",
|
||||
"name": "n8n PostgreSQL"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const deleted = $input.all().map(i => i.json.session_id).filter(Boolean);\nconsole.log(`[Cleanup] ${deleted.length} Session(s) gelöscht:`, deleted);\nreturn [{ json: { deleted_count: deleted.length, deleted_sessions: deleted } }];"
|
||||
},
|
||||
"id": "node-cd-004",
|
||||
"name": "Log Result",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [500, 300]
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"Jede Stunde": { "main": [[{ "node": "Delete Expired Sessions", "type": "main", "index": 0 }]] },
|
||||
"Delete Expired Sessions": { "main": [[{ "node": "Log Result", "type": "main", "index": 0 }]] }
|
||||
},
|
||||
"active": false,
|
||||
"settings": { "executionOrder": "v1" },
|
||||
"tags": []
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue