Spaces:
Running
Running
geekyrakshit
commited on
Commit
•
1f626ee
1
Parent(s):
78a1bf0
add: docs for regex model
Browse files- docs/metrics.md +3 -0
- docs/regex_model.md +11 -0
- guardrails_genie/regex_model.py +7 -8
- mkdocs.yml +2 -0
docs/metrics.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
# Metrics
|
2 |
+
|
3 |
+
::: guardrails_genie.metrics
|
docs/regex_model.md
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# RegexModel
|
2 |
+
|
3 |
+
!!! example "Sample Pattern"
|
4 |
+
```python
|
5 |
+
{
|
6 |
+
"email": r"[^@ \t\r\n]+@[^@ \t\r\n]+\.[^@ \t\r\n]+",
|
7 |
+
"phone": r"\b\d{3}[-.]?\d{3}[-.]?\d{4}\b"
|
8 |
+
}
|
9 |
+
```
|
10 |
+
|
11 |
+
::: guardrails_genie.regex_model
|
guardrails_genie/regex_model.py
CHANGED
@@ -12,17 +12,16 @@ class RegexResult(BaseModel):
|
|
12 |
|
13 |
|
14 |
class RegexModel(weave.Model):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
patterns: Dict[str, str]
|
16 |
|
17 |
def __init__(self, patterns: Dict[str, str]) -> None:
|
18 |
-
"""
|
19 |
-
Initialize RegexModel with a dictionary of patterns.
|
20 |
-
|
21 |
-
Args:
|
22 |
-
patterns: Dictionary where key is pattern name and value is regex pattern
|
23 |
-
Example: {"email": r"[^@ \t\r\n]+@[^@ \t\r\n]+\.[^@ \t\r\n]+",
|
24 |
-
"phone": r"\b\d{3}[-.]?\d{3}[-.]?\d{4}\b"}
|
25 |
-
"""
|
26 |
super().__init__(patterns=patterns)
|
27 |
self._compiled_patterns = {
|
28 |
name: re.compile(pattern) for name, pattern in patterns.items()
|
|
|
12 |
|
13 |
|
14 |
class RegexModel(weave.Model):
|
15 |
+
"""
|
16 |
+
Initialize RegexModel with a dictionary of patterns.
|
17 |
+
|
18 |
+
Args:
|
19 |
+
patterns (Dict[str, str]): Dictionary where key is pattern name and value is regex pattern.
|
20 |
+
"""
|
21 |
+
|
22 |
patterns: Dict[str, str]
|
23 |
|
24 |
def __init__(self, patterns: Dict[str, str]) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
super().__init__(patterns=patterns)
|
26 |
self._compiled_patterns = {
|
27 |
name: re.compile(pattern) for name, pattern in patterns.items()
|
mkdocs.yml
CHANGED
@@ -59,6 +59,8 @@ extra_javascript:
|
|
59 |
|
60 |
nav:
|
61 |
- Home: 'index.md'
|
|
|
|
|
62 |
- Utils: 'utils.md'
|
63 |
|
64 |
repo_url: https://github.com/soumik12345/guardrails-genie
|
|
|
59 |
|
60 |
nav:
|
61 |
- Home: 'index.md'
|
62 |
+
- Metrics: 'metrics.md'
|
63 |
+
- RegexModel: 'regex_model.md'
|
64 |
- Utils: 'utils.md'
|
65 |
|
66 |
repo_url: https://github.com/soumik12345/guardrails-genie
|