Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial commit #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions connectchain/lcel/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ class Logger(ABC):
def print(self, payload):
"""Send the payload to the desired component"""

@abstractmethod
def sanitize_output(self, payload):
"""Sanitize the payload to remove sensitive information"""

def log(self):
"""Return a lambda function that logs the payload"""

def _log_helper(payload: any):
self.sanitize_output(payload)
self.print(payload)
return payload

Expand Down
4 changes: 4 additions & 0 deletions connectchain/test/test_lcel_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
"""This is the unit test for the lcel_logger"""
import re
from unittest import TestCase

from connectchain.prompts import ValidPromptTemplate
Expand All @@ -23,6 +24,9 @@ def __init__(self):
def print(self, payload):
self.output = payload.text

def sanitize_output(self, str):
string = re.sub(r"^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$", "", payload)
self.output = string

TEMPLATE = "Give me 10 different {animal_type} species."

Expand Down