ragbits-guardrails 0.5.0__py3-none-any.whl → 1.4.0.dev202601310254__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,3 @@
1
- import base64
2
-
3
1
  from openai import AsyncOpenAI
4
2
 
5
3
  from ragbits.core.prompt import Prompt
@@ -27,18 +25,13 @@ class OpenAIModerationGuardrail(Guardrail):
27
25
  """
28
26
  if isinstance(input_to_verify, Prompt):
29
27
  inputs = [{"type": "text", "text": input_to_verify.rendered_user_prompt}]
28
+
30
29
  if input_to_verify.rendered_system_prompt is not None:
31
30
  inputs.append({"type": "text", "text": input_to_verify.rendered_system_prompt})
32
- if images := input_to_verify.images:
33
- inputs.extend(
34
- [
35
- {
36
- "type": "image_url",
37
- "image_url": {"url": f"data:image/jpeg;base64,{base64.b64encode(im).decode('utf-8')}"}, # type: ignore
38
- }
39
- for im in images
40
- ]
41
- )
31
+
32
+ if attachments := input_to_verify.attachments:
33
+ messages = [input_to_verify.create_message_with_attachment(attachment) for attachment in attachments]
34
+ inputs.extend(messages)
42
35
  else:
43
36
  inputs = [{"type": "text", "text": input_to_verify}]
44
37
  response = await self._openai_client.moderations.create(model=self._moderation_model, input=inputs) # type: ignore
File without changes
@@ -0,0 +1,65 @@
1
+ Metadata-Version: 2.4
2
+ Name: ragbits-guardrails
3
+ Version: 1.4.0.dev202601310254
4
+ Summary: Guardrails module for Ragbits components
5
+ Project-URL: Homepage, https://github.com/deepsense-ai/ragbits
6
+ Project-URL: Bug Reports, https://github.com/deepsense-ai/ragbits/issues
7
+ Project-URL: Documentation, https://ragbits.deepsense.ai/
8
+ Project-URL: Source, https://github.com/deepsense-ai/ragbits
9
+ Author-email: "deepsense.ai" <ragbits@deepsense.ai>
10
+ License-Expression: MIT
11
+ Keywords: Evaluation,GenAI,Generative AI,LLMs,Large Language Models,RAG,Retrieval Augmented Generation
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Natural Language :: English
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: ragbits-core==1.4.0.dev202601310254
26
+ Provides-Extra: openai
27
+ Requires-Dist: openai<2.0.0,>=1.91.0; extra == 'openai'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # Ragbits Guardrails
31
+
32
+ Ragbits Guardrails is a Python package that contains utilities for ensuring the safety and relevance of responses generated by Ragbits components.
33
+
34
+ ## Installation
35
+
36
+ You can install the latest version of Ragbits Guardrails using pip:
37
+
38
+ ```bash
39
+ pip install ragbits-guardrails
40
+ ```
41
+
42
+ ## Quickstart
43
+ Example of using the OpenAI Moderation Guardrail to verify a message:
44
+
45
+ ```python
46
+ import asyncio
47
+ from ragbits.guardrails.base import GuardrailManager, GuardrailVerificationResult
48
+ from ragbits.guardrails.openai_moderation import OpenAIModerationGuardrail
49
+
50
+
51
+ async def verify_message(message: str) -> list[GuardrailVerificationResult]:
52
+ manager = GuardrailManager([OpenAIModerationGuardrail()])
53
+ return await manager.verify(message)
54
+
55
+
56
+ if __name__ == '__main__':
57
+ print(asyncio.run(verify_message("Test message")))
58
+ ```
59
+
60
+ ## Documentation
61
+ * [How-To Guides - Guardrails](https://ragbits.deepsense.ai/how-to/use_guardrails/)
62
+ <!--
63
+ TODO:
64
+ * Add link to API Reference once classes from the Guardrails package are added to the API Reference.
65
+ -->
@@ -0,0 +1,7 @@
1
+ ragbits/guardrails/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ ragbits/guardrails/base.py,sha256=L8S4DcZnLNgs0hwEy4JQpmy7_1JFJbg-z4SKTBNvniY,1309
3
+ ragbits/guardrails/openai_moderation.py,sha256=B4-M7BjGiZl0gcVksYDquq3BNtuJajSJ3SPMiqmmeWs,1761
4
+ ragbits/guardrails/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ ragbits_guardrails-1.4.0.dev202601310254.dist-info/METADATA,sha256=ervjg0BSm1jYwL4ACQLAo6QSComWABnV_WMwIbA3r7Q,2426
6
+ ragbits_guardrails-1.4.0.dev202601310254.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
7
+ ragbits_guardrails-1.4.0.dev202601310254.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.26.3
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,30 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: ragbits-guardrails
3
- Version: 0.5.0
4
- Summary: Guardrails module for Ragbits components
5
- Project-URL: Homepage, https://github.com/deepsense-ai/ragbits
6
- Project-URL: Bug Reports, https://github.com/deepsense-ai/ragbits/issues
7
- Project-URL: Documentation, https://ragbits.deepsense.ai/
8
- Project-URL: Source, https://github.com/deepsense-ai/ragbits
9
- Author-email: "deepsense.ai" <ragbits@deepsense.ai>
10
- License: MIT
11
- Keywords: Evaluation,GenAI,Generative AI,LLMs,Large Language Models,RAG,Retrieval Augmented Generation
12
- Classifier: Development Status :: 4 - Beta
13
- Classifier: Environment :: Console
14
- Classifier: Intended Audience :: Science/Research
15
- Classifier: License :: OSI Approved :: MIT License
16
- Classifier: Natural Language :: English
17
- Classifier: Operating System :: OS Independent
18
- Classifier: Programming Language :: Python :: 3.10
19
- Classifier: Programming Language :: Python :: 3.11
20
- Classifier: Programming Language :: Python :: 3.12
21
- Classifier: Programming Language :: Python :: 3.13
22
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
- Requires-Python: >=3.10
25
- Requires-Dist: ragbits-core==0.5.0
26
- Provides-Extra: openai
27
- Requires-Dist: openai~=1.51.0; extra == 'openai'
28
- Description-Content-Type: text/markdown
29
-
30
- # Ragbits Guardrails
@@ -1,6 +0,0 @@
1
- ragbits/guardrails/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- ragbits/guardrails/base.py,sha256=L8S4DcZnLNgs0hwEy4JQpmy7_1JFJbg-z4SKTBNvniY,1309
3
- ragbits/guardrails/openai_moderation.py,sha256=sA_kXDBf-a8M1E6TG0fof3fQDOfOxLa4YbfZBJQCb6o,1973
4
- ragbits_guardrails-0.5.0.dist-info/METADATA,sha256=zx3FC4wyZrqo40m0qd4IzFf3PIrQUSS2NuQCte50TV0,1342
5
- ragbits_guardrails-0.5.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
6
- ragbits_guardrails-0.5.0.dist-info/RECORD,,