Skip to content

Commit c79ab39

Browse files
authored
update to be more developer focused
1 parent eded6a3 commit c79ab39

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,34 @@ Guardrails can be set up as a standalone service served by Flask with `guardrail
171171
172172
1. Install: `pip install "guardrails-ai"`
173173
2. Configure: `guardrails configure`
174-
3. Create a config: `guardrails create --validators=hub://guardrails/two_words --name=your-guard-name`
174+
3. Create a config: `guardrails create --validators=hub://guardrails/two_words --name=two-word-guard`
175175
4. Start the dev server: `guardrails start --config=./config.py`
176+
5. Interact with the dev server via the snippets below
177+
```
178+
# with the guardrails client
179+
import guardrails as gr
180+
181+
gr.settings.use_server = True
182+
guard = gr.Guard(name='two-word-guard')
183+
guard.validate('this is more than two words')
184+
185+
# or with the openai sdk
186+
import openai
187+
openai.base_url = "http://localhost:8000/guards/two-word-guard/openai/v1/"
188+
os.environ["OPENAI_API_KEY"] = "youropenaikey"
189+
190+
messages = [
191+
{
192+
"role": "user",
193+
"content": "tell me about an apple with 3 words exactly",
194+
},
195+
]
196+
197+
completion = openai.chat.completions.create(
198+
model="gpt-4o-mini",
199+
messages=messages,
200+
)
201+
```
176202
177203
For production deployments, we recommend using Docker with Gunicorn as the WSGI server for improved performance and scalability.
178204

0 commit comments

Comments
 (0)