Skip to content

Commit 2cb3ab1

Browse files
authored
Merge pull request #22 from guardrails-ai/dtam/openai_docs
add openai compatible endpoints to service spec
2 parents 191858a + b61733f commit 2cb3ab1

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed

resources/py/pyproject.toml.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "guardrails-api-client"
3-
version = "0.3.8"
3+
version = "0.3.9"
44
description = "Guardrails API Client."
55
authors = [
66
{name = "Guardrails AI", email = "[email protected]"}

resources/ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@guardrails-ai/api-client",
3-
"version": "0.3.8",
3+
"version": "0.3.9",
44
"description": "Client libaray for interacting with the guardrails-api",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

service-specs/guardrails-service-spec.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,36 @@ paths:
152152
application/json:
153153
schema:
154154
$ref: "#/components/schemas/HttpError"
155+
/guards/{guardName}/openai/v1/chat/completions:
156+
post:
157+
operationId: openaiChatCompletion
158+
tags:
159+
- openai
160+
summary: OpenAI SDK compatible endpoint for Chat Completions
161+
parameters:
162+
- $ref: "#/components/parameters/GuardName"
163+
security:
164+
- ApiKeyAuth: []
165+
- BearerAuth: []
166+
requestBody:
167+
required: true
168+
content:
169+
application/json:
170+
schema:
171+
$ref: "#/components/schemas/OpenAIChatCompletionPayload"
172+
responses:
173+
"200":
174+
description: The output of the completion
175+
content:
176+
application/json:
177+
schema:
178+
$ref: "#/components/schemas/OpenAIChatCompletion"
179+
default:
180+
description: Unexpected error
181+
content:
182+
application/json:
183+
schema:
184+
$ref: "#/components/schemas/HttpError"
155185
/guards/{guardName}/validate:
156186
post:
157187
operationId: validate
@@ -252,6 +282,59 @@ components:
252282
type: string
253283
format: password
254284
schemas:
285+
OpenAIChatCompletionPayload:
286+
type: object
287+
properties:
288+
model:
289+
type: string
290+
description: The model to use for the completion
291+
example: gpt-3.5-turbo
292+
messages:
293+
type: array
294+
items:
295+
type: object
296+
properties:
297+
role:
298+
type: string
299+
description: The role of the message
300+
content:
301+
type: string
302+
description: The content of the message
303+
description: The messages to use for the completion
304+
max_tokens:
305+
type: integer
306+
description: The maximum number of tokens to generate
307+
temperature:
308+
type: number
309+
description: The sampling temperature
310+
OpenAIChatCompletion:
311+
type: object
312+
properties:
313+
id:
314+
type: string
315+
description: The id
316+
created:
317+
type: string
318+
description: The created date
319+
model_name:
320+
type: string
321+
description: The model name
322+
choices:
323+
type: array
324+
items:
325+
type: object
326+
properties:
327+
role:
328+
type: string
329+
description: The role of the message
330+
content:
331+
type: string
332+
description: The content of the message
333+
required:
334+
- id
335+
- created
336+
- model_name
337+
- choices
255338
HttpError:
256339
type: object
257340
properties:

0 commit comments

Comments
 (0)