From 963cc2bb84cb259d7fc4994384b7a619293e5035 Mon Sep 17 00:00:00 2001 From: Caleb Courier Date: Fri, 23 Aug 2024 15:44:49 -0500 Subject: [PATCH] fix python deps; update docs to include openai route --- resources/py/README.md | 4 + resources/py/docs/OpenAIChatCompletion.md | 32 ++ .../py/docs/OpenAIChatCompletionPayload.md | 32 ++ ...penAIChatCompletionPayloadMessagesInner.md | 30 ++ resources/py/docs/OpenaiApi.md | 96 ++++++ resources/py/pyproject.toml.template | 5 +- resources/py/scripts/prebuild.js | 10 +- resources/ts/docs/classes/BaseAPI.md | 2 + resources/ts/docs/classes/OpenaiApi.md | 276 ++++++++++++++++++ .../docs/interfaces/OpenAIChatCompletion.md | 78 +++++ .../interfaces/OpenAIChatCompletionPayload.md | 80 +++++ ...penAIChatCompletionPayloadMessagesInner.md | 46 +++ .../ts/docs/interfaces/OpenaiApiInterface.md | 74 +++++ .../interfaces/OpenaiChatCompletionRequest.md | 30 ++ resources/ts/docs/modules.md | 267 +++++++++++++++++ resources/ts/package-lock.json | 4 +- resources/ts/package.json | 2 +- 17 files changed, 1059 insertions(+), 9 deletions(-) create mode 100644 resources/py/docs/OpenAIChatCompletion.md create mode 100644 resources/py/docs/OpenAIChatCompletionPayload.md create mode 100644 resources/py/docs/OpenAIChatCompletionPayloadMessagesInner.md create mode 100644 resources/py/docs/OpenaiApi.md create mode 100644 resources/ts/docs/classes/OpenaiApi.md create mode 100644 resources/ts/docs/interfaces/OpenAIChatCompletion.md create mode 100644 resources/ts/docs/interfaces/OpenAIChatCompletionPayload.md create mode 100644 resources/ts/docs/interfaces/OpenAIChatCompletionPayloadMessagesInner.md create mode 100644 resources/ts/docs/interfaces/OpenaiApiInterface.md create mode 100644 resources/ts/docs/interfaces/OpenaiChatCompletionRequest.md diff --git a/resources/py/README.md b/resources/py/README.md index fab7305..ef29806 100644 --- a/resources/py/README.md +++ b/resources/py/README.md @@ -45,6 +45,10 @@ bash ./py-build.sh - [LLMResponse](https://github.com/guardrails-ai/guardrails-api-client/tree/main/resources/py/docs/LLMResponse.md); - [MetaData](https://github.com/guardrails-ai/guardrails-api-client/tree/main/resources/py/docs/MetaData.md); - [ModelSchema](https://github.com/guardrails-ai/guardrails-api-client/tree/main/resources/py/docs/ModelSchema.md); + - [OpenAIChatCompletion](https://github.com/guardrails-ai/guardrails-api-client/tree/main/resources/py/docs/OpenAIChatCompletion.md); + - [OpenAIChatCompletionPayload](https://github.com/guardrails-ai/guardrails-api-client/tree/main/resources/py/docs/OpenAIChatCompletionPayload.md); + - [OpenAIChatCompletionPayloadMessagesInner](https://github.com/guardrails-ai/guardrails-api-client/tree/main/resources/py/docs/OpenAIChatCompletionPayloadMessagesInner.md); + - [OpenaiApi](https://github.com/guardrails-ai/guardrails-api-client/tree/main/resources/py/docs/OpenaiApi.md); - [Outputs](https://github.com/guardrails-ai/guardrails-api-client/tree/main/resources/py/docs/Outputs.md); - [OutputsParsedOutput](https://github.com/guardrails-ai/guardrails-api-client/tree/main/resources/py/docs/OutputsParsedOutput.md); - [OutputsValidationResponse](https://github.com/guardrails-ai/guardrails-api-client/tree/main/resources/py/docs/OutputsValidationResponse.md); diff --git a/resources/py/docs/OpenAIChatCompletion.md b/resources/py/docs/OpenAIChatCompletion.md new file mode 100644 index 0000000..7befb9f --- /dev/null +++ b/resources/py/docs/OpenAIChatCompletion.md @@ -0,0 +1,32 @@ +# OpenAIChatCompletion + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **str** | The id | +**created** | **str** | The created date | +**model_name** | **str** | The model name | +**choices** | [**List[OpenAIChatCompletionPayloadMessagesInner]**](OpenAIChatCompletionPayloadMessagesInner.md) | | + +## Example + +```python +from guardrails_api_client.models.open_ai_chat_completion import OpenAIChatCompletion + +# TODO update the JSON string below +json = "{}" +# create an instance of OpenAIChatCompletion from a JSON string +open_ai_chat_completion_instance = OpenAIChatCompletion.from_json(json) +# print the JSON string representation of the object +print(OpenAIChatCompletion.to_json()) + +# convert the object into a dict +open_ai_chat_completion_dict = open_ai_chat_completion_instance.to_dict() +# create an instance of OpenAIChatCompletion from a dict +open_ai_chat_completion_from_dict = OpenAIChatCompletion.from_dict(open_ai_chat_completion_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/resources/py/docs/OpenAIChatCompletionPayload.md b/resources/py/docs/OpenAIChatCompletionPayload.md new file mode 100644 index 0000000..cb2c2c7 --- /dev/null +++ b/resources/py/docs/OpenAIChatCompletionPayload.md @@ -0,0 +1,32 @@ +# OpenAIChatCompletionPayload + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**model** | **str** | The model to use for the completion | [optional] +**messages** | [**List[OpenAIChatCompletionPayloadMessagesInner]**](OpenAIChatCompletionPayloadMessagesInner.md) | The messages to use for the completion | [optional] +**max_tokens** | **int** | The maximum number of tokens to generate | [optional] +**temperature** | **float** | The sampling temperature | [optional] + +## Example + +```python +from guardrails_api_client.models.open_ai_chat_completion_payload import OpenAIChatCompletionPayload + +# TODO update the JSON string below +json = "{}" +# create an instance of OpenAIChatCompletionPayload from a JSON string +open_ai_chat_completion_payload_instance = OpenAIChatCompletionPayload.from_json(json) +# print the JSON string representation of the object +print(OpenAIChatCompletionPayload.to_json()) + +# convert the object into a dict +open_ai_chat_completion_payload_dict = open_ai_chat_completion_payload_instance.to_dict() +# create an instance of OpenAIChatCompletionPayload from a dict +open_ai_chat_completion_payload_from_dict = OpenAIChatCompletionPayload.from_dict(open_ai_chat_completion_payload_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/resources/py/docs/OpenAIChatCompletionPayloadMessagesInner.md b/resources/py/docs/OpenAIChatCompletionPayloadMessagesInner.md new file mode 100644 index 0000000..76afef7 --- /dev/null +++ b/resources/py/docs/OpenAIChatCompletionPayloadMessagesInner.md @@ -0,0 +1,30 @@ +# OpenAIChatCompletionPayloadMessagesInner + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**role** | **str** | The role of the message | [optional] +**content** | **str** | The content of the message | [optional] + +## Example + +```python +from guardrails_api_client.models.open_ai_chat_completion_payload_messages_inner import OpenAIChatCompletionPayloadMessagesInner + +# TODO update the JSON string below +json = "{}" +# create an instance of OpenAIChatCompletionPayloadMessagesInner from a JSON string +open_ai_chat_completion_payload_messages_inner_instance = OpenAIChatCompletionPayloadMessagesInner.from_json(json) +# print the JSON string representation of the object +print(OpenAIChatCompletionPayloadMessagesInner.to_json()) + +# convert the object into a dict +open_ai_chat_completion_payload_messages_inner_dict = open_ai_chat_completion_payload_messages_inner_instance.to_dict() +# create an instance of OpenAIChatCompletionPayloadMessagesInner from a dict +open_ai_chat_completion_payload_messages_inner_from_dict = OpenAIChatCompletionPayloadMessagesInner.from_dict(open_ai_chat_completion_payload_messages_inner_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/resources/py/docs/OpenaiApi.md b/resources/py/docs/OpenaiApi.md new file mode 100644 index 0000000..0f1f728 --- /dev/null +++ b/resources/py/docs/OpenaiApi.md @@ -0,0 +1,96 @@ +# guardrails_api_client.OpenaiApi + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**openai_chat_completion**](OpenaiApi.md#openai_chat_completion) | **POST** /guards/{guardName}/openai/v1/chat/completions | OpenAI SDK compatible endpoint for Chat Completions + + +# **openai_chat_completion** +> OpenAIChatCompletion openai_chat_completion(guard_name, open_ai_chat_completion_payload) + +OpenAI SDK compatible endpoint for Chat Completions + +### Example + +* Api Key Authentication (ApiKeyAuth): +* Bearer (JWT) Authentication (BearerAuth): + +```python +import guardrails_api_client +from guardrails_api_client.models.open_ai_chat_completion import OpenAIChatCompletion +from guardrails_api_client.models.open_ai_chat_completion_payload import OpenAIChatCompletionPayload +from guardrails_api_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = guardrails_api_client.Configuration( + host = "http://localhost" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: ApiKeyAuth +configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer' + +# Configure Bearer authorization (JWT): BearerAuth +configuration = guardrails_api_client.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with guardrails_api_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = guardrails_api_client.OpenaiApi(api_client) + guard_name = 'guard_name_example' # str | Guard name + open_ai_chat_completion_payload = guardrails_api_client.OpenAIChatCompletionPayload() # OpenAIChatCompletionPayload | + + try: + # OpenAI SDK compatible endpoint for Chat Completions + api_response = api_instance.openai_chat_completion(guard_name, open_ai_chat_completion_payload) + print("The response of OpenaiApi->openai_chat_completion:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling OpenaiApi->openai_chat_completion: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **guard_name** | **str**| Guard name | + **open_ai_chat_completion_payload** | [**OpenAIChatCompletionPayload**](OpenAIChatCompletionPayload.md)| | + +### Return type + +[**OpenAIChatCompletion**](OpenAIChatCompletion.md) + +### Authorization + +[ApiKeyAuth](../README.md#ApiKeyAuth), [BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | The output of the completion | - | +**0** | Unexpected error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/resources/py/pyproject.toml.template b/resources/py/pyproject.toml.template index f65015a..689aa12 100644 --- a/resources/py/pyproject.toml.template +++ b/resources/py/pyproject.toml.template @@ -27,4 +27,7 @@ testpaths = [ ] [tool.pyright] -include = ["guardrails_api_client"] \ No newline at end of file +include = ["guardrails_api_client"] + +[tool.ruff.lint] +ignore = ["E721"] \ No newline at end of file diff --git a/resources/py/scripts/prebuild.js b/resources/py/scripts/prebuild.js index c7ead68..9d9bba9 100644 --- a/resources/py/scripts/prebuild.js +++ b/resources/py/scripts/prebuild.js @@ -41,7 +41,7 @@ ${ } function updateDependencies () { - const pyProjectToml = fs.readFileSync( + let pyProjectToml = fs.readFileSync( path.resolve('./pyproject.toml.template') ).toString(); const requirementsTxt = fs.readFileSync( @@ -52,13 +52,13 @@ function updateDependencies () { const dependencies = `dependencies = [ ${ requirements - .map(r => `"${r.trim().split('\s').join('')}"`) - .join('\n') + .filter(r => r.length > 0) + .map(r => `\t"${r.trim().split('\s').join('')}"`) + .join(',\n') } ]`; - pyProjectToml.replace('dependencies = []', dependencies) - + pyProjectToml = pyProjectToml.replace('dependencies = []', dependencies) fs.writeFileSync( diff --git a/resources/ts/docs/classes/BaseAPI.md b/resources/ts/docs/classes/BaseAPI.md index e940ff2..46a3a7b 100644 --- a/resources/ts/docs/classes/BaseAPI.md +++ b/resources/ts/docs/classes/BaseAPI.md @@ -10,6 +10,8 @@ This is the base class for all generated API classes. ↳ [`GuardApi`](GuardApi.md) + ↳ [`OpenaiApi`](OpenaiApi.md) + ↳ [`ServiceHealthApi`](ServiceHealthApi.md) ↳ [`ValidateApi`](ValidateApi.md) diff --git a/resources/ts/docs/classes/OpenaiApi.md b/resources/ts/docs/classes/OpenaiApi.md new file mode 100644 index 0000000..0fd1bfe --- /dev/null +++ b/resources/ts/docs/classes/OpenaiApi.md @@ -0,0 +1,276 @@ +[@guardrails-ai/api-client](../README.md) / [Exports](../modules.md) / OpenaiApi + +# Class: OpenaiApi + +## Hierarchy + +- [`BaseAPI`](BaseAPI.md) + + ↳ **`OpenaiApi`** + +## Implements + +- [`OpenaiApiInterface`](../interfaces/OpenaiApiInterface.md) + +## Table of contents + +### Constructors + +- [constructor](OpenaiApi.md#constructor) + +### Properties + +- [configuration](OpenaiApi.md#configuration) + +### Methods + +- [isJsonMime](OpenaiApi.md#isjsonmime) +- [openaiChatCompletion](OpenaiApi.md#openaichatcompletion) +- [openaiChatCompletionRaw](OpenaiApi.md#openaichatcompletionraw) +- [request](OpenaiApi.md#request) +- [withMiddleware](OpenaiApi.md#withmiddleware) +- [withPostMiddleware](OpenaiApi.md#withpostmiddleware) +- [withPreMiddleware](OpenaiApi.md#withpremiddleware) + +## Constructors + +### constructor + +• **new OpenaiApi**(`configuration?`): [`OpenaiApi`](OpenaiApi.md) + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `configuration` | [`Configuration`](Configuration.md) | `DefaultConfig` | + +#### Returns + +[`OpenaiApi`](OpenaiApi.md) + +#### Inherited from + +[BaseAPI](BaseAPI.md).[constructor](BaseAPI.md#constructor) + +#### Defined in + +src/runtime.ts:110 + +## Properties + +### configuration + +• `Protected` **configuration**: [`Configuration`](Configuration.md) = `DefaultConfig` + +#### Inherited from + +[BaseAPI](BaseAPI.md).[configuration](BaseAPI.md#configuration) + +#### Defined in + +src/runtime.ts:110 + +## Methods + +### isJsonMime + +▸ **isJsonMime**(`mime`): `boolean` + +Check if the given MIME is a JSON MIME. +JSON MIME examples: + application/json + application/json; charset=UTF8 + APPLICATION/JSON + application/vnd.company+json + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `mime` | `undefined` \| ``null`` \| `string` | MIME (Multipurpose Internet Mail Extensions) | + +#### Returns + +`boolean` + +True if the given MIME is JSON, false otherwise. + +#### Inherited from + +[BaseAPI](BaseAPI.md).[isJsonMime](BaseAPI.md#isjsonmime) + +#### Defined in + +src/runtime.ts:146 + +___ + +### openaiChatCompletion + +▸ **openaiChatCompletion**(`requestParameters`, `initOverrides?`): `Promise`\<[`OpenAIChatCompletion`](../interfaces/OpenAIChatCompletion.md)\> + +OpenAI SDK compatible endpoint for Chat Completions + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `requestParameters` | [`OpenaiChatCompletionRequest`](../interfaces/OpenaiChatCompletionRequest.md) | +| `initOverrides?` | `RequestInit` \| [`InitOverrideFunction`](../modules.md#initoverridefunction) | + +#### Returns + +`Promise`\<[`OpenAIChatCompletion`](../interfaces/OpenAIChatCompletion.md)\> + +#### Implementation of + +[OpenaiApiInterface](../interfaces/OpenaiApiInterface.md).[openaiChatCompletion](../interfaces/OpenaiApiInterface.md#openaichatcompletion) + +#### Defined in + +src/apis/OpenaiApi.ts:128 + +___ + +### openaiChatCompletionRaw + +▸ **openaiChatCompletionRaw**(`requestParameters`, `initOverrides?`): `Promise`\<[`ApiResponse`](../interfaces/ApiResponse.md)\<[`OpenAIChatCompletion`](../interfaces/OpenAIChatCompletion.md)\>\> + +OpenAI SDK compatible endpoint for Chat Completions + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `requestParameters` | [`OpenaiChatCompletionRequest`](../interfaces/OpenaiChatCompletionRequest.md) | +| `initOverrides?` | `RequestInit` \| [`InitOverrideFunction`](../modules.md#initoverridefunction) | + +#### Returns + +`Promise`\<[`ApiResponse`](../interfaces/ApiResponse.md)\<[`OpenAIChatCompletion`](../interfaces/OpenAIChatCompletion.md)\>\> + +#### Implementation of + +[OpenaiApiInterface](../interfaces/OpenaiApiInterface.md).[openaiChatCompletionRaw](../interfaces/OpenaiApiInterface.md#openaichatcompletionraw) + +#### Defined in + +src/apis/OpenaiApi.ts:67 + +___ + +### request + +▸ **request**(`context`, `initOverrides?`): `Promise`\<`Response`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `context` | [`RequestOpts`](../interfaces/RequestOpts.md) | +| `initOverrides?` | `RequestInit` \| [`InitOverrideFunction`](../modules.md#initoverridefunction) | + +#### Returns + +`Promise`\<`Response`\> + +#### Inherited from + +[BaseAPI](BaseAPI.md).[request](BaseAPI.md#request) + +#### Defined in + +src/runtime.ts:153 + +___ + +### withMiddleware + +▸ **withMiddleware**\<`T`\>(`this`, `...middlewares`): `T` + +#### Type parameters + +| Name | Type | +| :------ | :------ | +| `T` | extends [`BaseAPI`](BaseAPI.md) | + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `this` | `T` | +| `...middlewares` | [`Middleware`](../interfaces/Middleware.md)[] | + +#### Returns + +`T` + +#### Inherited from + +[BaseAPI](BaseAPI.md).[withMiddleware](BaseAPI.md#withmiddleware) + +#### Defined in + +src/runtime.ts:114 + +___ + +### withPostMiddleware + +▸ **withPostMiddleware**\<`T`\>(`this`, `...postMiddlewares`): `T` + +#### Type parameters + +| Name | Type | +| :------ | :------ | +| `T` | extends [`BaseAPI`](BaseAPI.md) | + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `this` | `T` | +| `...postMiddlewares` | (`undefined` \| (`context`: [`ResponseContext`](../interfaces/ResponseContext.md)) => `Promise`\<`void` \| `Response`\>)[] | + +#### Returns + +`T` + +#### Inherited from + +[BaseAPI](BaseAPI.md).[withPostMiddleware](BaseAPI.md#withpostmiddleware) + +#### Defined in + +src/runtime.ts:128 + +___ + +### withPreMiddleware + +▸ **withPreMiddleware**\<`T`\>(`this`, `...preMiddlewares`): `T` + +#### Type parameters + +| Name | Type | +| :------ | :------ | +| `T` | extends [`BaseAPI`](BaseAPI.md) | + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `this` | `T` | +| `...preMiddlewares` | (`undefined` \| (`context`: [`RequestContext`](../interfaces/RequestContext.md)) => `Promise`\<`void` \| [`FetchParams`](../interfaces/FetchParams.md)\>)[] | + +#### Returns + +`T` + +#### Inherited from + +[BaseAPI](BaseAPI.md).[withPreMiddleware](BaseAPI.md#withpremiddleware) + +#### Defined in + +src/runtime.ts:120 diff --git a/resources/ts/docs/interfaces/OpenAIChatCompletion.md b/resources/ts/docs/interfaces/OpenAIChatCompletion.md new file mode 100644 index 0000000..c87d9cb --- /dev/null +++ b/resources/ts/docs/interfaces/OpenAIChatCompletion.md @@ -0,0 +1,78 @@ +[@guardrails-ai/api-client](../README.md) / [Exports](../modules.md) / OpenAIChatCompletion + +# Interface: OpenAIChatCompletion + +**`Export`** + +OpenAIChatCompletion + +## Table of contents + +### Properties + +- [choices](OpenAIChatCompletion.md#choices) +- [created](OpenAIChatCompletion.md#created) +- [id](OpenAIChatCompletion.md#id) +- [modelName](OpenAIChatCompletion.md#modelname) + +## Properties + +### choices + +• **choices**: [`OpenAIChatCompletionPayloadMessagesInner`](OpenAIChatCompletionPayloadMessagesInner.md)[] + +**`Memberof`** + +OpenAIChatCompletion + +#### Defined in + +src/models/OpenAIChatCompletion.ts:50 + +___ + +### created + +• **created**: `string` + +The created date + +**`Memberof`** + +OpenAIChatCompletion + +#### Defined in + +src/models/OpenAIChatCompletion.ts:38 + +___ + +### id + +• **id**: `string` + +The id + +**`Memberof`** + +OpenAIChatCompletion + +#### Defined in + +src/models/OpenAIChatCompletion.ts:32 + +___ + +### modelName + +• **modelName**: `string` + +The model name + +**`Memberof`** + +OpenAIChatCompletion + +#### Defined in + +src/models/OpenAIChatCompletion.ts:44 diff --git a/resources/ts/docs/interfaces/OpenAIChatCompletionPayload.md b/resources/ts/docs/interfaces/OpenAIChatCompletionPayload.md new file mode 100644 index 0000000..145c322 --- /dev/null +++ b/resources/ts/docs/interfaces/OpenAIChatCompletionPayload.md @@ -0,0 +1,80 @@ +[@guardrails-ai/api-client](../README.md) / [Exports](../modules.md) / OpenAIChatCompletionPayload + +# Interface: OpenAIChatCompletionPayload + +**`Export`** + +OpenAIChatCompletionPayload + +## Table of contents + +### Properties + +- [maxTokens](OpenAIChatCompletionPayload.md#maxtokens) +- [messages](OpenAIChatCompletionPayload.md#messages) +- [model](OpenAIChatCompletionPayload.md#model) +- [temperature](OpenAIChatCompletionPayload.md#temperature) + +## Properties + +### maxTokens + +• `Optional` **maxTokens**: `number` + +The maximum number of tokens to generate + +**`Memberof`** + +OpenAIChatCompletionPayload + +#### Defined in + +src/models/OpenAIChatCompletionPayload.ts:44 + +___ + +### messages + +• `Optional` **messages**: [`OpenAIChatCompletionPayloadMessagesInner`](OpenAIChatCompletionPayloadMessagesInner.md)[] + +The messages to use for the completion + +**`Memberof`** + +OpenAIChatCompletionPayload + +#### Defined in + +src/models/OpenAIChatCompletionPayload.ts:38 + +___ + +### model + +• `Optional` **model**: `string` + +The model to use for the completion + +**`Memberof`** + +OpenAIChatCompletionPayload + +#### Defined in + +src/models/OpenAIChatCompletionPayload.ts:32 + +___ + +### temperature + +• `Optional` **temperature**: `number` + +The sampling temperature + +**`Memberof`** + +OpenAIChatCompletionPayload + +#### Defined in + +src/models/OpenAIChatCompletionPayload.ts:50 diff --git a/resources/ts/docs/interfaces/OpenAIChatCompletionPayloadMessagesInner.md b/resources/ts/docs/interfaces/OpenAIChatCompletionPayloadMessagesInner.md new file mode 100644 index 0000000..f11dc8b --- /dev/null +++ b/resources/ts/docs/interfaces/OpenAIChatCompletionPayloadMessagesInner.md @@ -0,0 +1,46 @@ +[@guardrails-ai/api-client](../README.md) / [Exports](../modules.md) / OpenAIChatCompletionPayloadMessagesInner + +# Interface: OpenAIChatCompletionPayloadMessagesInner + +**`Export`** + +OpenAIChatCompletionPayloadMessagesInner + +## Table of contents + +### Properties + +- [content](OpenAIChatCompletionPayloadMessagesInner.md#content) +- [role](OpenAIChatCompletionPayloadMessagesInner.md#role) + +## Properties + +### content + +• `Optional` **content**: `string` + +The content of the message + +**`Memberof`** + +OpenAIChatCompletionPayloadMessagesInner + +#### Defined in + +src/models/OpenAIChatCompletionPayloadMessagesInner.ts:32 + +___ + +### role + +• `Optional` **role**: `string` + +The role of the message + +**`Memberof`** + +OpenAIChatCompletionPayloadMessagesInner + +#### Defined in + +src/models/OpenAIChatCompletionPayloadMessagesInner.ts:26 diff --git a/resources/ts/docs/interfaces/OpenaiApiInterface.md b/resources/ts/docs/interfaces/OpenaiApiInterface.md new file mode 100644 index 0000000..a002212 --- /dev/null +++ b/resources/ts/docs/interfaces/OpenaiApiInterface.md @@ -0,0 +1,74 @@ +[@guardrails-ai/api-client](../README.md) / [Exports](../modules.md) / OpenaiApiInterface + +# Interface: OpenaiApiInterface + +OpenaiApi - interface + +**`Export`** + +OpenaiApiInterface + +## Implemented by + +- [`OpenaiApi`](../classes/OpenaiApi.md) + +## Table of contents + +### Methods + +- [openaiChatCompletion](OpenaiApiInterface.md#openaichatcompletion) +- [openaiChatCompletionRaw](OpenaiApiInterface.md#openaichatcompletionraw) + +## Methods + +### openaiChatCompletion + +▸ **openaiChatCompletion**(`requestParameters`, `initOverrides?`): `Promise`\<[`OpenAIChatCompletion`](OpenAIChatCompletion.md)\> + +OpenAI SDK compatible endpoint for Chat Completions + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `requestParameters` | [`OpenaiChatCompletionRequest`](OpenaiChatCompletionRequest.md) | +| `initOverrides?` | `RequestInit` \| [`InitOverrideFunction`](../modules.md#initoverridefunction) | + +#### Returns + +`Promise`\<[`OpenAIChatCompletion`](OpenAIChatCompletion.md)\> + +#### Defined in + +src/apis/OpenaiApi.ts:54 + +___ + +### openaiChatCompletionRaw + +▸ **openaiChatCompletionRaw**(`requestParameters`, `initOverrides?`): `Promise`\<[`ApiResponse`](ApiResponse.md)\<[`OpenAIChatCompletion`](OpenAIChatCompletion.md)\>\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `requestParameters` | [`OpenaiChatCompletionRequest`](OpenaiChatCompletionRequest.md) | +| `initOverrides?` | `RequestInit` \| [`InitOverrideFunction`](../modules.md#initoverridefunction) | + +#### Returns + +`Promise`\<[`ApiResponse`](ApiResponse.md)\<[`OpenAIChatCompletion`](OpenAIChatCompletion.md)\>\> + +**`Summary`** + +OpenAI SDK compatible endpoint for Chat Completions + +**`Throws`** + +**`Memberof`** + +OpenaiApiInterface + +#### Defined in + +src/apis/OpenaiApi.ts:46 diff --git a/resources/ts/docs/interfaces/OpenaiChatCompletionRequest.md b/resources/ts/docs/interfaces/OpenaiChatCompletionRequest.md new file mode 100644 index 0000000..7408a8f --- /dev/null +++ b/resources/ts/docs/interfaces/OpenaiChatCompletionRequest.md @@ -0,0 +1,30 @@ +[@guardrails-ai/api-client](../README.md) / [Exports](../modules.md) / OpenaiChatCompletionRequest + +# Interface: OpenaiChatCompletionRequest + +## Table of contents + +### Properties + +- [guardName](OpenaiChatCompletionRequest.md#guardname) +- [openAIChatCompletionPayload](OpenaiChatCompletionRequest.md#openaichatcompletionpayload) + +## Properties + +### guardName + +• **guardName**: `string` + +#### Defined in + +src/apis/OpenaiApi.ts:26 + +___ + +### openAIChatCompletionPayload + +• **openAIChatCompletionPayload**: [`OpenAIChatCompletionPayload`](OpenAIChatCompletionPayload.md) + +#### Defined in + +src/apis/OpenaiApi.ts:27 diff --git a/resources/ts/docs/modules.md b/resources/ts/docs/modules.md index bd3bd2a..d44b17f 100644 --- a/resources/ts/docs/modules.md +++ b/resources/ts/docs/modules.md @@ -12,6 +12,7 @@ - [FetchError](classes/FetchError.md) - [GuardApi](classes/GuardApi.md) - [JSONApiResponse](classes/JSONApiResponse.md) +- [OpenaiApi](classes/OpenaiApi.md) - [RequiredError](classes/RequiredError.md) - [ResponseError](classes/ResponseError.md) - [ServiceHealthApi](classes/ServiceHealthApi.md) @@ -50,6 +51,11 @@ - [LLMResponse](interfaces/LLMResponse.md) - [MetaData](interfaces/MetaData.md) - [Middleware](interfaces/Middleware.md) +- [OpenAIChatCompletion](interfaces/OpenAIChatCompletion.md) +- [OpenAIChatCompletionPayload](interfaces/OpenAIChatCompletionPayload.md) +- [OpenAIChatCompletionPayloadMessagesInner](interfaces/OpenAIChatCompletionPayloadMessagesInner.md) +- [OpenaiApiInterface](interfaces/OpenaiApiInterface.md) +- [OpenaiChatCompletionRequest](interfaces/OpenaiChatCompletionRequest.md) - [Outputs](interfaces/Outputs.md) - [OutputsParsedOutput](interfaces/OutputsParsedOutput.md) - [OutputsValidationResponse](interfaces/OutputsValidationResponse.md) @@ -165,6 +171,15 @@ - [MetaDataFromJSON](modules.md#metadatafromjson) - [MetaDataFromJSONTyped](modules.md#metadatafromjsontyped) - [MetaDataToJSON](modules.md#metadatatojson) +- [OpenAIChatCompletionFromJSON](modules.md#openaichatcompletionfromjson) +- [OpenAIChatCompletionFromJSONTyped](modules.md#openaichatcompletionfromjsontyped) +- [OpenAIChatCompletionPayloadFromJSON](modules.md#openaichatcompletionpayloadfromjson) +- [OpenAIChatCompletionPayloadFromJSONTyped](modules.md#openaichatcompletionpayloadfromjsontyped) +- [OpenAIChatCompletionPayloadMessagesInnerFromJSON](modules.md#openaichatcompletionpayloadmessagesinnerfromjson) +- [OpenAIChatCompletionPayloadMessagesInnerFromJSONTyped](modules.md#openaichatcompletionpayloadmessagesinnerfromjsontyped) +- [OpenAIChatCompletionPayloadMessagesInnerToJSON](modules.md#openaichatcompletionpayloadmessagesinnertojson) +- [OpenAIChatCompletionPayloadToJSON](modules.md#openaichatcompletionpayloadtojson) +- [OpenAIChatCompletionToJSON](modules.md#openaichatcompletiontojson) - [OutputsFromJSON](modules.md#outputsfromjson) - [OutputsFromJSONTyped](modules.md#outputsfromjsontyped) - [OutputsParsedOutputFromJSON](modules.md#outputsparsedoutputfromjson) @@ -242,6 +257,9 @@ - [instanceOfLLMResource](modules.md#instanceofllmresource) - [instanceOfLLMResponse](modules.md#instanceofllmresponse) - [instanceOfMetaData](modules.md#instanceofmetadata) +- [instanceOfOpenAIChatCompletion](modules.md#instanceofopenaichatcompletion) +- [instanceOfOpenAIChatCompletionPayload](modules.md#instanceofopenaichatcompletionpayload) +- [instanceOfOpenAIChatCompletionPayloadMessagesInner](modules.md#instanceofopenaichatcompletionpayloadmessagesinner) - [instanceOfOutputs](modules.md#instanceofoutputs) - [instanceOfOutputsParsedOutput](modules.md#instanceofoutputsparsedoutput) - [instanceOfOutputsValidationResponse](modules.md#instanceofoutputsvalidationresponse) @@ -1790,6 +1808,189 @@ src/models/MetaData.ts:94 ___ +### OpenAIChatCompletionFromJSON + +▸ **OpenAIChatCompletionFromJSON**(`json`): [`OpenAIChatCompletion`](interfaces/OpenAIChatCompletion.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `json` | `any` | + +#### Returns + +[`OpenAIChatCompletion`](interfaces/OpenAIChatCompletion.md) + +#### Defined in + +src/models/OpenAIChatCompletion.ts:64 + +___ + +### OpenAIChatCompletionFromJSONTyped + +▸ **OpenAIChatCompletionFromJSONTyped**(`json`, `ignoreDiscriminator`): [`OpenAIChatCompletion`](interfaces/OpenAIChatCompletion.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `json` | `any` | +| `ignoreDiscriminator` | `boolean` | + +#### Returns + +[`OpenAIChatCompletion`](interfaces/OpenAIChatCompletion.md) + +#### Defined in + +src/models/OpenAIChatCompletion.ts:68 + +___ + +### OpenAIChatCompletionPayloadFromJSON + +▸ **OpenAIChatCompletionPayloadFromJSON**(`json`): [`OpenAIChatCompletionPayload`](interfaces/OpenAIChatCompletionPayload.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `json` | `any` | + +#### Returns + +[`OpenAIChatCompletionPayload`](interfaces/OpenAIChatCompletionPayload.md) + +#### Defined in + +src/models/OpenAIChatCompletionPayload.ts:60 + +___ + +### OpenAIChatCompletionPayloadFromJSONTyped + +▸ **OpenAIChatCompletionPayloadFromJSONTyped**(`json`, `ignoreDiscriminator`): [`OpenAIChatCompletionPayload`](interfaces/OpenAIChatCompletionPayload.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `json` | `any` | +| `ignoreDiscriminator` | `boolean` | + +#### Returns + +[`OpenAIChatCompletionPayload`](interfaces/OpenAIChatCompletionPayload.md) + +#### Defined in + +src/models/OpenAIChatCompletionPayload.ts:66 + +___ + +### OpenAIChatCompletionPayloadMessagesInnerFromJSON + +▸ **OpenAIChatCompletionPayloadMessagesInnerFromJSON**(`json`): [`OpenAIChatCompletionPayloadMessagesInner`](interfaces/OpenAIChatCompletionPayloadMessagesInner.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `json` | `any` | + +#### Returns + +[`OpenAIChatCompletionPayloadMessagesInner`](interfaces/OpenAIChatCompletionPayloadMessagesInner.md) + +#### Defined in + +src/models/OpenAIChatCompletionPayloadMessagesInner.ts:44 + +___ + +### OpenAIChatCompletionPayloadMessagesInnerFromJSONTyped + +▸ **OpenAIChatCompletionPayloadMessagesInnerFromJSONTyped**(`json`, `ignoreDiscriminator`): [`OpenAIChatCompletionPayloadMessagesInner`](interfaces/OpenAIChatCompletionPayloadMessagesInner.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `json` | `any` | +| `ignoreDiscriminator` | `boolean` | + +#### Returns + +[`OpenAIChatCompletionPayloadMessagesInner`](interfaces/OpenAIChatCompletionPayloadMessagesInner.md) + +#### Defined in + +src/models/OpenAIChatCompletionPayloadMessagesInner.ts:50 + +___ + +### OpenAIChatCompletionPayloadMessagesInnerToJSON + +▸ **OpenAIChatCompletionPayloadMessagesInnerToJSON**(`value?`): `any` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `value?` | ``null`` \| [`OpenAIChatCompletionPayloadMessagesInner`](interfaces/OpenAIChatCompletionPayloadMessagesInner.md) | + +#### Returns + +`any` + +#### Defined in + +src/models/OpenAIChatCompletionPayloadMessagesInner.ts:63 + +___ + +### OpenAIChatCompletionPayloadToJSON + +▸ **OpenAIChatCompletionPayloadToJSON**(`value?`): `any` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `value?` | ``null`` \| [`OpenAIChatCompletionPayload`](interfaces/OpenAIChatCompletionPayload.md) | + +#### Returns + +`any` + +#### Defined in + +src/models/OpenAIChatCompletionPayload.ts:86 + +___ + +### OpenAIChatCompletionToJSON + +▸ **OpenAIChatCompletionToJSON**(`value?`): `any` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `value?` | ``null`` \| [`OpenAIChatCompletion`](interfaces/OpenAIChatCompletion.md) | + +#### Returns + +`any` + +#### Defined in + +src/models/OpenAIChatCompletion.ts:85 + +___ + ### OutputsFromJSON ▸ **OutputsFromJSON**(`json`): [`Outputs`](interfaces/Outputs.md) @@ -3385,6 +3586,72 @@ src/models/MetaData.ts:68 ___ +### instanceOfOpenAIChatCompletion + +▸ **instanceOfOpenAIChatCompletion**(`value`): `boolean` + +Check if a given object implements the OpenAIChatCompletion interface. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `value` | `object` | + +#### Returns + +`boolean` + +#### Defined in + +src/models/OpenAIChatCompletion.ts:56 + +___ + +### instanceOfOpenAIChatCompletionPayload + +▸ **instanceOfOpenAIChatCompletionPayload**(`value`): `boolean` + +Check if a given object implements the OpenAIChatCompletionPayload interface. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `value` | `object` | + +#### Returns + +`boolean` + +#### Defined in + +src/models/OpenAIChatCompletionPayload.ts:56 + +___ + +### instanceOfOpenAIChatCompletionPayloadMessagesInner + +▸ **instanceOfOpenAIChatCompletionPayloadMessagesInner**(`value`): `boolean` + +Check if a given object implements the OpenAIChatCompletionPayloadMessagesInner interface. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `value` | `object` | + +#### Returns + +`boolean` + +#### Defined in + +src/models/OpenAIChatCompletionPayloadMessagesInner.ts:38 + +___ + ### instanceOfOutputs ▸ **instanceOfOutputs**(`value`): `boolean` diff --git a/resources/ts/package-lock.json b/resources/ts/package-lock.json index ee811cc..9eb3efd 100644 --- a/resources/ts/package-lock.json +++ b/resources/ts/package-lock.json @@ -1,12 +1,12 @@ { "name": "@guardrails-ai/api-client", - "version": "0.3.8", + "version": "0.3.10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@guardrails-ai/api-client", - "version": "0.3.8", + "version": "0.3.10", "license": "Apache-2.0", "devDependencies": { "@types/node": "^20.12.11", diff --git a/resources/ts/package.json b/resources/ts/package.json index 79428eb..334f464 100644 --- a/resources/ts/package.json +++ b/resources/ts/package.json @@ -1,6 +1,6 @@ { "name": "@guardrails-ai/api-client", - "version": "0.3.9", + "version": "0.3.10", "description": "Client libaray for interacting with the guardrails-api", "main": "dist/index.js", "types": "dist/index.d.ts",