Skip to content

Commit

Permalink
Exclude password from serialization (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 authored Aug 27, 2024
1 parent eaa1cff commit fdbfc66
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lumen/ai/assistant.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import asyncio
import re

from io import StringIO
from typing import Literal
Expand Down Expand Up @@ -423,7 +424,7 @@ async def _get_agent(self, messages: list | str):
step.success_title = f"Selected {subagent.name[:-5]}"
return selected

def _serialize(self, obj):
def _serialize(self, obj, exclude_passwords=True):
if isinstance(obj, (Tabs, Column)):
for o in obj:
if isinstance(obj, ChatStep) and not obj.title.startswith("Selected"):
Expand All @@ -433,7 +434,10 @@ def _serialize(self, obj):
break
else:
return ""
return self._serialize(o)
string = self._serialize(o)
if exclude_passwords:
string = re.sub(r"password:.*\n", "", string)
return string

if isinstance(obj, HTML) and 'catalog' in obj.tags:
return f"Summarized table listing: {obj.object[:30]}"
Expand Down

0 comments on commit fdbfc66

Please sign in to comment.