enkryptai-sdk 1.0.14__tar.gz → 1.0.16__tar.gz

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.
Files changed (46) hide show
  1. {enkryptai_sdk-1.0.14/src/enkryptai_sdk.egg-info → enkryptai_sdk-1.0.16}/PKG-INFO +319 -6
  2. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/README.md +318 -5
  3. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/setup.py +1 -1
  4. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/dto/guardrails.py +13 -0
  5. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/dto/models.py +5 -3
  6. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/dto/red_team.py +178 -0
  7. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/models.py +37 -89
  8. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/red_team.py +28 -0
  9. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16/src/enkryptai_sdk.egg-info}/PKG-INFO +319 -6
  10. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/tests/test_all_v2.py +29 -203
  11. enkryptai_sdk-1.0.16/tests/test_redteam.py +258 -0
  12. enkryptai_sdk-1.0.14/tests/test_redteam.py +0 -434
  13. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/LICENSE +0 -0
  14. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/setup.cfg +0 -0
  15. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/__init__.py +0 -0
  16. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/ai_proxy.py +0 -0
  17. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/base.py +0 -0
  18. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/coc.py +0 -0
  19. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/config.py +0 -0
  20. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/datasets.py +0 -0
  21. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/deployments.py +0 -0
  22. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/dto/__init__.py +0 -0
  23. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/dto/ai_proxy.py +0 -0
  24. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/dto/base.py +0 -0
  25. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/dto/coc.py +0 -0
  26. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/dto/datasets.py +0 -0
  27. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/dto/deployments.py +0 -0
  28. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/evals.py +0 -0
  29. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/guardrails.py +0 -0
  30. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/guardrails_old.py +0 -0
  31. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk/response.py +0 -0
  32. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk.egg-info/SOURCES.txt +0 -0
  33. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk.egg-info/dependency_links.txt +0 -0
  34. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/src/enkryptai_sdk.egg-info/top_level.txt +0 -0
  35. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/tests/test_ai_proxy.py +0 -0
  36. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/tests/test_all.py +0 -0
  37. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/tests/test_basic.py +0 -0
  38. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/tests/test_coc.py +0 -0
  39. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/tests/test_datasets.py +0 -0
  40. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/tests/test_deployments.py +0 -0
  41. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/tests/test_detect_policy.py +0 -0
  42. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/tests/test_guardrails.py +0 -0
  43. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/tests/test_injection_attack.py +0 -0
  44. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/tests/test_model.py +0 -0
  45. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/tests/test_openai.py +0 -0
  46. {enkryptai_sdk-1.0.14 → enkryptai_sdk-1.0.16}/tests/test_policy_violation.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: enkryptai-sdk
3
- Version: 1.0.14
3
+ Version: 1.0.16
4
4
  Summary: A Python SDK with guardrails and red teaming functionality for API interactions
5
5
  Home-page: https://github.com/enkryptai/enkryptai-sdk
6
6
  Author: Enkrypt AI Team
@@ -49,6 +49,8 @@ Also see the API documentation at [https://docs.enkryptai.com](https://docs.enkr
49
49
  - [Sample Redteam Model Config](#sample-redteam-model-config)
50
50
  - [Sample Custom Redteam Target Config](#sample-custom-redteam-target-config)
51
51
  - [Sample Custom Redteam Model Config](#sample-custom-redteam-model-config)
52
+ - [Sample Redteam Risk Mitigation Guardrails Policy Config](#sample-redteam-risk-mitigation-guardrails-policy-config)
53
+ - [Sample Redteam Risk Mitigation System Prompt Config](#sample-redteam-risk-mitigation-system-prompt-config)
52
54
  - [Health Checks](#health-checks)
53
55
  - [Guardrails Health](#guardrails-health)
54
56
  - [Guardrails Status](#guardrails-status)
@@ -124,6 +126,8 @@ Also see the API documentation at [https://docs.enkryptai.com](https://docs.enkr
124
126
  - [Get Redteam Task Results Summary of Test Type](#get-redteam-task-results-summary-of-test-type)
125
127
  - [Get Redteam Task Results Details](#get-redteam-task-results-details)
126
128
  - [Get Redteam Task Results Details of Test Type](#get-redteam-task-results-details-of-test-type)
129
+ - [Mitigate Risks with Guardrails Policy](#mitigate-risks-with-guardrails-policy)
130
+ - [Mitigate Risks with System Prompt](#mitigate-risks-with-system-prompt)
127
131
  - [Copyright, License, and Terms of Use](#copyright-license-and-terms-of-use)
128
132
 
129
133
  ## Installation
@@ -518,6 +522,289 @@ sample_custom_redteam_model_config = {
518
522
  }
519
523
  ```
520
524
 
525
+ ### [Sample Redteam Risk Mitigation Guardrails Policy Config](https://docs.enkryptai.com/redteam-api-reference/endpoint/risk-mitigation-guardrails-policy)
526
+
527
+ ```python Python
528
+ sample_redteam_risk_mitigation_guardrails_policy_config = {
529
+ "redteam_summary": {
530
+ "category": [
531
+ {
532
+ "Biology": {
533
+ "total": 50,
534
+ "test_type": "cbrn_test",
535
+ "success(%)": 92
536
+ }
537
+ },
538
+ {
539
+ "Chemistry": {
540
+ "total": 50,
541
+ "test_type": "cbrn_test",
542
+ "success(%)": 98
543
+ }
544
+ },
545
+ {
546
+ "Fraud": {
547
+ "total": 100,
548
+ "test_type": "harmful_test",
549
+ "success(%)": 73
550
+ }
551
+ },
552
+ {
553
+ "Guns & Illegal Substances": {
554
+ "total": 100,
555
+ "test_type": "harmful_test",
556
+ "success(%)": 87
557
+ }
558
+ },
559
+ {
560
+ "Hate Speech and Discrimination": {
561
+ "total": 100,
562
+ "test_type": "harmful_test",
563
+ "success(%)": 53
564
+ }
565
+ },
566
+ {
567
+ "Nuclear Science": {
568
+ "total": 50,
569
+ "test_type": "cbrn_test",
570
+ "success(%)": 94
571
+ }
572
+ },
573
+ {
574
+ "Radiology": {
575
+ "total": 50,
576
+ "test_type": "cbrn_test",
577
+ "success(%)": 84
578
+ }
579
+ },
580
+ {
581
+ "Regulated or Controlled Substances": {
582
+ "total": 100,
583
+ "test_type": "harmful_test",
584
+ "success(%)": 74
585
+ }
586
+ },
587
+ {
588
+ "Sexual Content": {
589
+ "total": 100,
590
+ "test_type": "harmful_test",
591
+ "success(%)": 79
592
+ }
593
+ },
594
+ {
595
+ "Suicide & Self-Harm": {
596
+ "total": 100,
597
+ "test_type": "harmful_test",
598
+ "success(%)": 72
599
+ }
600
+ },
601
+ {
602
+ "Unethical Crimes": {
603
+ "total": 100,
604
+ "test_type": "harmful_test",
605
+ "success(%)": 83
606
+ }
607
+ },
608
+ {
609
+ "Violent Crimes": {
610
+ "total": 100,
611
+ "test_type": "harmful_test",
612
+ "success(%)": 70
613
+ }
614
+ }
615
+ ],
616
+ "scenario": [],
617
+ "test_date": "2020-01-01T17:14:33.607823+00:00",
618
+ "test_name": "Mistral Small Latest x Red Team",
619
+ "test_type": [
620
+ {
621
+ "cbrn_test": {
622
+ "total": 200,
623
+ "success(%)": 92
624
+ }
625
+ },
626
+ {
627
+ "harmful_test": {
628
+ "total": 800,
629
+ "success(%)": 73.88
630
+ }
631
+ }
632
+ ],
633
+ "model_name": "mistral-small-latest",
634
+ "risk_score": 82.9375,
635
+ "dataset_name": "Standard",
636
+ "model_source": "",
637
+ "attack_method": [
638
+ {
639
+ "Basic": {
640
+ "total": 1000,
641
+ "success(%)": 77.5
642
+ }
643
+ }
644
+ ],
645
+ "nist_category": [
646
+ {
647
+ "CBRN Information or Capabilities": {
648
+ "total": 200,
649
+ "success(%)": 92
650
+ }
651
+ },
652
+ {
653
+ "Dangerous, Violent, or Hateful Content": {
654
+ "total": 800,
655
+ "success(%)": 73.88
656
+ }
657
+ }
658
+ ],
659
+ "model_provider": "mistral",
660
+ "model_endpoint_url": "https://api.mistral.ai/v1/chat/completions",
661
+ "custom_test_category_risks": []
662
+ }
663
+ }
664
+ ```
665
+
666
+ ### [Sample Redteam Risk Mitigation System Prompt Config](https://docs.enkryptai.com/redteam-api-reference/endpoint/risk-mitigation-system-prompt)
667
+
668
+ ```python Python
669
+ sample_redteam_risk_mitigation_system_prompt_config = {
670
+ "system_prompt": "You are a helpful AI Assistant",
671
+ "redteam_summary": {
672
+ "category": [
673
+ {
674
+ "Biology": {
675
+ "total": 50,
676
+ "test_type": "cbrn_test",
677
+ "success(%)": 92
678
+ }
679
+ },
680
+ {
681
+ "Chemistry": {
682
+ "total": 50,
683
+ "test_type": "cbrn_test",
684
+ "success(%)": 98
685
+ }
686
+ },
687
+ {
688
+ "Fraud": {
689
+ "total": 100,
690
+ "test_type": "harmful_test",
691
+ "success(%)": 73
692
+ }
693
+ },
694
+ {
695
+ "Guns & Illegal Substances": {
696
+ "total": 100,
697
+ "test_type": "harmful_test",
698
+ "success(%)": 87
699
+ }
700
+ },
701
+ {
702
+ "Hate Speech and Discrimination": {
703
+ "total": 100,
704
+ "test_type": "harmful_test",
705
+ "success(%)": 53
706
+ }
707
+ },
708
+ {
709
+ "Nuclear Science": {
710
+ "total": 50,
711
+ "test_type": "cbrn_test",
712
+ "success(%)": 94
713
+ }
714
+ },
715
+ {
716
+ "Radiology": {
717
+ "total": 50,
718
+ "test_type": "cbrn_test",
719
+ "success(%)": 84
720
+ }
721
+ },
722
+ {
723
+ "Regulated or Controlled Substances": {
724
+ "total": 100,
725
+ "test_type": "harmful_test",
726
+ "success(%)": 74
727
+ }
728
+ },
729
+ {
730
+ "Sexual Content": {
731
+ "total": 100,
732
+ "test_type": "harmful_test",
733
+ "success(%)": 79
734
+ }
735
+ },
736
+ {
737
+ "Suicide & Self-Harm": {
738
+ "total": 100,
739
+ "test_type": "harmful_test",
740
+ "success(%)": 72
741
+ }
742
+ },
743
+ {
744
+ "Unethical Crimes": {
745
+ "total": 100,
746
+ "test_type": "harmful_test",
747
+ "success(%)": 83
748
+ }
749
+ },
750
+ {
751
+ "Violent Crimes": {
752
+ "total": 100,
753
+ "test_type": "harmful_test",
754
+ "success(%)": 70
755
+ }
756
+ }
757
+ ],
758
+ "scenario": [],
759
+ "test_date": "2020-01-01T17:14:33.607823+00:00",
760
+ "test_name": "Mistral Small Latest x Red Team",
761
+ "test_type": [
762
+ {
763
+ "cbrn_test": {
764
+ "total": 200,
765
+ "success(%)": 92
766
+ }
767
+ },
768
+ {
769
+ "harmful_test": {
770
+ "total": 800,
771
+ "success(%)": 73.88
772
+ }
773
+ }
774
+ ],
775
+ "model_name": "mistral-small-latest",
776
+ "risk_score": 82.9375,
777
+ "dataset_name": "Standard",
778
+ "model_source": "",
779
+ "attack_method": [
780
+ {
781
+ "Basic": {
782
+ "total": 1000,
783
+ "success(%)": 77.5
784
+ }
785
+ }
786
+ ],
787
+ "nist_category": [
788
+ {
789
+ "CBRN Information or Capabilities": {
790
+ "total": 200,
791
+ "success(%)": 92
792
+ }
793
+ },
794
+ {
795
+ "Dangerous, Violent, or Hateful Content": {
796
+ "total": 800,
797
+ "success(%)": 73.88
798
+ }
799
+ }
800
+ ],
801
+ "model_provider": "mistral",
802
+ "model_endpoint_url": "https://api.mistral.ai/v1/chat/completions",
803
+ "custom_test_category_risks": []
804
+ }
805
+ }
806
+ ```
807
+
521
808
  ## Health Checks
522
809
 
523
810
  ### [Guardrails Health](https://docs.enkryptai.com/guardrails-api-reference/endpoint/health-check)
@@ -694,8 +981,8 @@ print(batch_detect_response.to_dict())
694
981
  - `nsfw`: Filter inappropriate content
695
982
  - `toxicity`: Detect toxic language
696
983
  - `pii`: Detect personal information
697
- - `copyright_ip`: Check for copyright/IP violations *(Coming soon)*
698
- - `system_prompt`: Detect system prompt leaks *(Coming soon)*
984
+ - `copyright_ip`: Check for copyright/IP violations ***(Coming soon)***
985
+ - `system_prompt`: Detect system prompt leaks ***(Coming soon)***
699
986
  - `keyword_detector`: Check for specific keywords
700
987
 
701
988
  Each detector can be enabled/disabled and configured with specific options as documented in the [API docs](https://docs.enkryptai.com/guardrails-api-reference/introduction).
@@ -757,7 +1044,7 @@ guardrails_config = GuardrailsConfig.keyword(keywords=["secret", "password"])
757
1044
 
758
1045
  ### [Copyright IP](https://docs.enkryptai.com/guardrails-api-reference/Copyright_IP_Leak_Detector)
759
1046
 
760
- *(Coming soon)*
1047
+ - ***(Coming soon)***
761
1048
 
762
1049
  ```python Python
763
1050
  guardrails_config = GuardrailsConfig.copyright_ip()
@@ -765,7 +1052,7 @@ guardrails_config = GuardrailsConfig.copyright_ip()
765
1052
 
766
1053
  ### [System Prompt](https://docs.enkryptai.com/guardrails-api-reference/System_Prompt_Leak_Detector)
767
1054
 
768
- *(Coming soon)*
1055
+ - ***(Coming soon)***
769
1056
 
770
1057
  ```python Python
771
1058
  guardrails_config = GuardrailsConfig.system_prompt(index="system")
@@ -969,7 +1256,7 @@ print(relevancy_response.to_dict())
969
1256
 
970
1257
  ### [Check Hallucination](https://docs.enkryptai.com/guardrails-api-reference/Hallucination)
971
1258
 
972
- *(Coming soon)*
1259
+ - ***(Coming soon)***
973
1260
 
974
1261
  Detect hallucinations in an LLM's response:
975
1262
 
@@ -1660,6 +1947,32 @@ print(redteam_results_details_test_type.task_status)
1660
1947
  print(redteam_results_details_test_type.to_dict())
1661
1948
  ```
1662
1949
 
1950
+ ### [Mitigate Risks with Guardrails Policy](https://docs.enkryptai.com/redteam-api-reference/endpoint/risk-mitigation-guardrails-policy)
1951
+
1952
+ ```python Python
1953
+ # Mitigate risks with guardrails policy
1954
+ risk_mitigation_guardrails_policy_response = redteam_client.risk_mitigation_guardrails_policy(config=copy.deepcopy(sample_redteam_risk_mitigation_guardrails_policy_config))
1955
+
1956
+ print(risk_mitigation_guardrails_policy_response)
1957
+ print(risk_mitigation_guardrails_policy_response.guardrails_policy)
1958
+
1959
+ # Print as a dictionary
1960
+ print(risk_mitigation_guardrails_policy_response.to_dict())
1961
+ ```
1962
+
1963
+ ### [Mitigate Risks with System Prompt](https://docs.enkryptai.com/redteam-api-reference/endpoint/risk-mitigation-system-prompt)
1964
+
1965
+ ```python Python
1966
+ # Mitigate risks with system prompt
1967
+ risk_mitigation_system_prompt_response = redteam_client.risk_mitigation_system_prompt(config=copy.deepcopy(sample_redteam_risk_mitigation_system_prompt_config))
1968
+
1969
+ print(risk_mitigation_system_prompt_response)
1970
+ print(risk_mitigation_system_prompt_response.system_prompt)
1971
+
1972
+ # Print as a dictionary
1973
+ print(risk_mitigation_system_prompt_response.to_dict())
1974
+ ```
1975
+
1663
1976
  ## Copyright, License and Terms of Use
1664
1977
 
1665
1978
  © 2025 Enkrypt AI. All rights reserved.