File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -171,8 +171,34 @@ Guardrails can be set up as a standalone service served by Flask with `guardrail
171171
1721721. Install: `pip install "guardrails-ai"`
1731732. 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 `
1751754. 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
177203For production deployments, we recommend using Docker with Gunicorn as the WSGI server for improved performance and scalability.
178204
You can’t perform that action at this time.
0 commit comments