|
5 | 5 | project_url: https://github.com/owndev/Open-WebUI-Functions |
6 | 6 | funding_url: https://github.com/sponsors/owndev |
7 | 7 | n8n_template: https://github.com/owndev/Open-WebUI-Functions/blob/main/pipelines/n8n/Open_WebUI_Test_Agent_Streaming.json |
8 | | -version: 2.1.1 |
| 8 | +version: 2.1.2 |
9 | 9 | license: Apache License 2.0 |
10 | 10 | description: An optimized streaming-enabled pipeline for interacting with N8N workflows, consistent response handling for both streaming and non-streaming modes, robust error handling, and simplified status management. Supports Server-Sent Events (SSE) streaming and various N8N workflow formats. |
11 | 11 | features: |
@@ -286,6 +286,10 @@ class Valves(BaseModel): |
286 | 286 | default="output", |
287 | 287 | description="Field name for the response message in the N8N payload", |
288 | 288 | ) |
| 289 | + SEND_CONVERSATION_HISTORY: bool = Field( |
| 290 | + default=False, |
| 291 | + description="Whether to include conversation history when sending requests to N8N", |
| 292 | + ) |
289 | 293 | CF_ACCESS_CLIENT_ID: EncryptedStr = Field( |
290 | 294 | default="", |
291 | 295 | description="Only if behind Cloudflare: https://developers.cloudflare.com/cloudflare-one/identity/service-tokens/", |
@@ -544,18 +548,24 @@ async def pipe( |
544 | 548 | if messages and messages[0].get("role") == "system": |
545 | 549 | system_prompt = self.dedupe_system_prompt(messages[0]["content"]) |
546 | 550 |
|
547 | | - # Include full conversation history like in stream-example.py |
| 551 | + # Optionally include full conversation history (controlled by valve) |
548 | 552 | conversation_history = [] |
549 | | - for msg in messages: |
550 | | - if msg.get("role") in ["user", "assistant"]: |
551 | | - conversation_history.append( |
552 | | - {"role": msg["role"], "content": msg["content"]} |
553 | | - ) |
| 553 | + if self.valves.SEND_CONVERSATION_HISTORY: |
| 554 | + for msg in messages: |
| 555 | + if msg.get("role") in ["user", "assistant"]: |
| 556 | + conversation_history.append( |
| 557 | + {"role": msg["role"], "content": msg["content"]} |
| 558 | + ) |
554 | 559 |
|
555 | 560 | # Prepare payload for N8N workflow (improved version) |
556 | 561 | payload = { |
557 | 562 | "systemPrompt": system_prompt, |
558 | | - "messages": conversation_history, # Full conversation context |
| 563 | + # Include messages only when enabled in valves for privacy/control |
| 564 | + "messages": ( |
| 565 | + conversation_history |
| 566 | + if self.valves.SEND_CONVERSATION_HISTORY |
| 567 | + else [] |
| 568 | + ), |
559 | 569 | "currentMessage": question, # Current user message |
560 | 570 | "user_id": __user__.get("id") if __user__ else None, |
561 | 571 | "user_email": __user__.get("email") if __user__ else None, |
|
0 commit comments