Last active
          December 9, 2024 06:39 
        
      - 
      
- 
        Save goofansu/ee731baddc7b51db817f08137d48a95f to your computer and use it in GitHub Desktop. 
Revisions
- 
        Yejun Su revised this gist Dec 9, 2024 . 2 changed files with 1 addition and 3 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,5 +14,4 @@ ) print("Role:", response.choices[0].message.role) print("Content:", response.choices[0].message.content) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,4 +15,3 @@ print("Role:", response.choices[0].message.role) print("Content:", response.choices[0].message.content) 
- 
        Yejun Su revised this gist Dec 9, 2024 . 2 changed files with 18 additions and 0 deletions.There are no files selected for viewingFile renamed without changes.This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ import os from openai import OpenAI client = OpenAI( base_url='https://openrouter.ai/api/v1', ) response = client.chat.completions.create( model="anthropic/claude-3-5-haiku", messages=[{ "role": "user", "content": "Fake a person email and name." }] ) print("Role:", response.choices[0].message.role) print("Content:", response.choices[0].message.content) print("Valid?", response.guardrails['validation_passed']) 
- 
        Yejun Su revised this gist Dec 9, 2024 . No changes.There are no files selected for viewing
- 
        Yejun Su revised this gist Dec 9, 2024 . No changes.There are no files selected for viewing
- 
        Yejun Su revised this gist Dec 9, 2024 . No changes.There are no files selected for viewing
- 
        Yejun Su revised this gist Dec 9, 2024 . No changes.There are no files selected for viewing
- 
        Yejun Su revised this gist Dec 9, 2024 . No changes.There are no files selected for viewing
- 
        Yejun Su revised this gist Dec 9, 2024 . No changes.There are no files selected for viewing
- 
        Yejun Su created this gist Dec 9, 2024 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ import os from openai import OpenAI client = OpenAI( base_url='http://127.0.0.1:8000/guards/my-first-guard/openai/v1', ) response = client.chat.completions.create( model="openrouter/anthropic/claude-3-5-haiku", messages=[{ "role": "user", "content": "Fake a person email and name." }] ) print("Role:", response.choices[0].message.role) print("Content:", response.choices[0].message.content) print("Valid?", response.guardrails['validation_passed']) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ import os from guardrails import Guard from guardrails.hub import ( DetectPII, GibberishText ) guard = Guard() guard.name = 'my-first-guard' guard.use_many( DetectPII(pii_entities="pii", on_fail="fix"), GibberishText(on_fail="fix"), ) 
 Yejun Su
              revised
            
            this gist
            
              Yejun Su
              revised
            
            this gist