Skip to content

Commit

Permalink
Merge pull request #5 from guardrails-ai/fix-build
Browse files Browse the repository at this point in the history
Fix build
  • Loading branch information
AlejandroEsquivel authored Jan 28, 2025
2 parents 5155005 + f5dd8ff commit d40e9c7
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 31 deletions.
39 changes: 34 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,39 @@ on:
jobs:
setup:
runs-on: ubuntu-latest
env:
GUARDRAILS_TOKEN: ${{ secrets.GR_GUARDRAILS_TOKEN }}
PYPI_REPOSITORY_URL: 'https://pypi.guardrailsai.com'
steps:
- name: Build & Deploy
uses: guardrails-ai/guardrails/.github/actions/validator_pypi_publish@main
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
guardrails_token: ${{ secrets.GR_GUARDRAILS_TOKEN }}
validator_id: guardrails/simlab_client
package_directory: 'client_wrapper'
python-version: '3.11'

- name: Install Twine & Build
shell: bash
run: |
python -m pip install --upgrade pip
pip install twine build toml
- name: Create .pypirc
shell: bash
run: |
touch ~/.pypirc
echo "[distutils]" >> ~/.pypirc
echo "index-servers =" >> ~/.pypirc
echo " private-repository" >> ~/.pypirc
echo "" >> ~/.pypirc
echo "[private-repository]" >> ~/.pypirc
echo "repository = $PYPI_REPOSITORY_URL" >> ~/.pypirc
echo "username = __token__" >> ~/.pypirc
echo "password = $GUARDRAILS_TOKEN" >> ~/.pypirc
- name: Build & Upload
shell: bash
run: |
python -m build
twine upload dist/* -u __token__ -p $GUARDRAILS_TOKEN -r private-repository
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,6 @@ cython_debug/

# MacOS
.DS_Store

# Local scripts
*.sh
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export GUARDRAILS_TOKEN=$(cat ~/.guardrailsrc| awk -F 'token=' '{print $2}' | aw

# Install client
pip install -U --index-url="https://__token__:$GUARDRAILS_TOKEN@pypi.guardrailsai.com/simple" \
--extra-index-url="https://pypi.org/simple" guardrails-grhub-simlab-client
--extra-index-url="https://pypi.org/simple" guardrails-ai-simlab-client
```

## Sample llm Usage

```python
from guardrails_grhub_simlab_client import tt_webhook_polling_sync
from guardrails_simlab_client import simlab_connect

@tt_webhook_polling_sync(enable=True)
@simlab_connect(enable=True)
def my_application_interface(user_message):
# Your existing logic
# 1. Call LLM API directly
Expand All @@ -42,14 +42,14 @@ def my_application_interface(user_message):
When using one of our specific preview environments one can override our server's URL with:

```python
@tt_webhook_polling_sync(enable=True, control_plane_host="http://...")
@simlab_connect(enable=True, control_plane_host="http://...")
def my_application_interface(user_message):
...
```

## Sample custom judge usage
```python
from guardrails_grhub_simlab_client import custom_judge, JudgeResult
from guardrails_simlab_client import custom_judge, JudgeResult

@custom_judge(risk_name="Toxic Language", enable=True, application_id="41bddba7-feaf-40e2-ba28-9daf22a1ec71")
def custom_judge_fn(
Expand Down
9 changes: 0 additions & 9 deletions client_wrapper/__init__.py

This file was deleted.

4 changes: 2 additions & 2 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# This is just a utility class that defines and runs the client_wrapper.
import os
from client_wrapper import tt_webhook_polling_sync
from guardrails_simlab_client import simlab_connect
from litellm import litellm

CONTROL_PLANE_URL = os.getenv("CONTROL_PLANE_URL", "http://gr-threat-tester-prod-ctrl-svc.gr-threat-tester-prod.priv.local:8080")

@tt_webhook_polling_sync(enable=True, control_plane_host=CONTROL_PLANE_URL)
@simlab_connect(enable=True, control_plane_host=CONTROL_PLANE_URL)
def generate_with_huge_llm(messages) -> str:
print(f"Running generate_with_huge_llm: {messages}")
res = litellm.completion(
Expand Down
11 changes: 11 additions & 0 deletions guardrails_simlab_client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from guardrails_simlab_client.decorators.llm import tt_webhook_polling_sync
from guardrails_simlab_client.decorators.llm import tt_webhook_polling_sync as simlab_connect
from guardrails_simlab_client.decorators.custom_judge import custom_judge
from guardrails_simlab_client.protocols import JudgeResult

__all__ = [
"custom_judge",
"tt_webhook_polling_sync",
"JudgeResult",
"simlab_connect"
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from urllib.parse import quote_plus

import requests
from client_wrapper.env import CONTROL_PLANE_URL, _get_api_key, _get_app_id
from client_wrapper.protocols import JudgeResult
from client_wrapper.processors.risk_evaluation_processor import RiskEvaluationProcessor
from guardrails_simlab_client.env import CONTROL_PLANE_URL, _get_api_key, _get_app_id
from guardrails_simlab_client.protocols import JudgeResult
from guardrails_simlab_client.processors.risk_evaluation_processor import RiskEvaluationProcessor

LOGGER = getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import time
import requests

from client_wrapper.env import CONTROL_PLANE_URL, _get_api_key, _get_app_id
from client_wrapper.processors.test_processor import TestProcessor
from guardrails_simlab_client.env import CONTROL_PLANE_URL, _get_api_key, _get_app_id
from guardrails_simlab_client.processors.test_processor import TestProcessor

LOGGER = getLogger(__name__)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Callable, Dict, Optional

import requests
from client_wrapper.env import _get_api_key, _get_app_id
from guardrails_simlab_client.env import _get_api_key, _get_app_id

LOGGER = getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

from queue import Queue
import threading
from client_wrapper.protocols import Report
from client_wrapper.env import CONTROL_PLANE_URL, _get_api_key, _get_app_id
from guardrails_simlab_client.protocols import Report
from guardrails_simlab_client.env import _get_api_key, _get_app_id

LOGGER = getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

from dataclasses import dataclass
from enum import Enum
from typing import Dict, Optional

@dataclass
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "guardrails-ai-simlab-client"
version = "0.1.3"
version = "0.2.0"
authors = [
{name = "Guardrails AI", email = "[email protected]"}
]
Expand Down

0 comments on commit d40e9c7

Please sign in to comment.