diff --git a/src/backend/langflow/api/v1/callback.py b/src/backend/langflow/api/v1/callback.py index 69dbf5082..d465f8684 100644 --- a/src/backend/langflow/api/v1/callback.py +++ b/src/backend/langflow/api/v1/callback.py @@ -104,6 +104,15 @@ class AsyncStreamingLLMCallbackHandler(AsyncCallbackHandler): # This runs when first sending the prompt # to the LLM, adding it will send the final prompt # to the frontend + if "Prompt after formatting" in text: + text = text.replace("Prompt after formatting", "") + resp = ChatResponse( + message="", + type="stream", + intermediate_steps="", + prompt=text, + ) + await self.websocket.send_json(resp.dict()) async def on_agent_action(self, action: AgentAction, **kwargs: Any): log = f"Thought: {action.log}" diff --git a/src/backend/langflow/api/v1/schemas.py b/src/backend/langflow/api/v1/schemas.py index de0348d38..27de03083 100644 --- a/src/backend/langflow/api/v1/schemas.py +++ b/src/backend/langflow/api/v1/schemas.py @@ -61,6 +61,7 @@ class ChatResponse(ChatMessage): """Chat response schema.""" intermediate_steps: str + prompt: Optional[str] = "" type: str is_bot: bool = True files: list = []