Skip to content

Latest commit

 

History

History
435 lines (297 loc) · 15.5 KB

File metadata and controls

435 lines (297 loc) · 15.5 KB

cms_client.OperationsCompatibleWithOpenAIAPIsApi

All URIs are relative to http://localhost

Method HTTP request Description
embed_texts POST /openai/v1/embeddings Embed Texts
generate_chat_completions POST /openai/v1/chat/completions Generate Chat Completions
generate_text_completions POST /openai/v1/completions Generate Text Completions
get_model GET /openai/v1/models/{model_name} Get Model
list_models GET /openai/v1/models List Models

embed_texts

object embed_texts(open_ai_embeddings_request, tracking_id=tracking_id)

Embed Texts

Create embeddings based on text(s), similar to OpenAI's /v1/embeddings endpoint

Example

  • OAuth Authentication (OAuth2PasswordBearer):
  • Api Key Authentication (APIKeyCookie):
import cms_client
from cms_client.models.open_ai_embeddings_request import OpenAIEmbeddingsRequest
from cms_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 = cms_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.

configuration.access_token = os.environ["ACCESS_TOKEN"]

# Configure API key authorization: APIKeyCookie
configuration.api_key['APIKeyCookie'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['APIKeyCookie'] = 'Bearer'

# Enter a context with an instance of the API client
with cms_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cms_client.OperationsCompatibleWithOpenAIAPIsApi(api_client)
    open_ai_embeddings_request = cms_client.OpenAIEmbeddingsRequest() # OpenAIEmbeddingsRequest | 
    tracking_id = 'tracking_id_example' # str | The tracking ID of the requested task (optional)

    try:
        # Embed Texts
        api_response = api_instance.embed_texts(open_ai_embeddings_request, tracking_id=tracking_id)
        print("The response of OperationsCompatibleWithOpenAIAPIsApi->embed_texts:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling OperationsCompatibleWithOpenAIAPIsApi->embed_texts: %s\n" % e)

Parameters

Name Type Description Notes
open_ai_embeddings_request OpenAIEmbeddingsRequest
tracking_id str The tracking ID of the requested task [optional]

Return type

object

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful Response -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

generate_chat_completions

object generate_chat_completions(open_ai_chat_completions_request, ensure_full_sentences=ensure_full_sentences, chat_template=chat_template, tracking_id=tracking_id)

Generate Chat Completions

Generate chat response based on messages, similar to OpenAI's /v1/chat/completions

Example

  • OAuth Authentication (OAuth2PasswordBearer):
  • Api Key Authentication (APIKeyCookie):
import cms_client
from cms_client.models.open_ai_chat_completions_request import OpenAIChatCompletionsRequest
from cms_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 = cms_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.

configuration.access_token = os.environ["ACCESS_TOKEN"]

# Configure API key authorization: APIKeyCookie
configuration.api_key['APIKeyCookie'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['APIKeyCookie'] = 'Bearer'

# Enter a context with an instance of the API client
with cms_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cms_client.OperationsCompatibleWithOpenAIAPIsApi(api_client)
    open_ai_chat_completions_request = cms_client.OpenAIChatCompletionsRequest() # OpenAIChatCompletionsRequest | 
    ensure_full_sentences = False # bool | Whether to generate full sentences only (optional) (default to False)
    chat_template = 'chat_template_example' # str | Override chat template for prompt formatting (optional)
    tracking_id = 'tracking_id_example' # str | The tracking ID of the requested task (optional)

    try:
        # Generate Chat Completions
        api_response = api_instance.generate_chat_completions(open_ai_chat_completions_request, ensure_full_sentences=ensure_full_sentences, chat_template=chat_template, tracking_id=tracking_id)
        print("The response of OperationsCompatibleWithOpenAIAPIsApi->generate_chat_completions:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling OperationsCompatibleWithOpenAIAPIsApi->generate_chat_completions: %s\n" % e)

Parameters

Name Type Description Notes
open_ai_chat_completions_request OpenAIChatCompletionsRequest
ensure_full_sentences bool Whether to generate full sentences only [optional] [default to False]
chat_template str Override chat template for prompt formatting [optional]
tracking_id str The tracking ID of the requested task [optional]

Return type

object

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful Response -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

generate_text_completions

object generate_text_completions(open_ai_completions_request, ensure_full_sentences=ensure_full_sentences, chat_template=chat_template, tracking_id=tracking_id)

Generate Text Completions

Generate completion based on prompt, similar to OpenAI's /v1/completions

Example

  • OAuth Authentication (OAuth2PasswordBearer):
  • Api Key Authentication (APIKeyCookie):
import cms_client
from cms_client.models.open_ai_completions_request import OpenAICompletionsRequest
from cms_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 = cms_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.

configuration.access_token = os.environ["ACCESS_TOKEN"]

# Configure API key authorization: APIKeyCookie
configuration.api_key['APIKeyCookie'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['APIKeyCookie'] = 'Bearer'

# Enter a context with an instance of the API client
with cms_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cms_client.OperationsCompatibleWithOpenAIAPIsApi(api_client)
    open_ai_completions_request = cms_client.OpenAICompletionsRequest() # OpenAICompletionsRequest | 
    ensure_full_sentences = False # bool | Whether to generate full sentences only (optional) (default to False)
    chat_template = 'chat_template_example' # str | Override chat template for prompt formatting (optional)
    tracking_id = 'tracking_id_example' # str | The tracking ID of the requested task (optional)

    try:
        # Generate Text Completions
        api_response = api_instance.generate_text_completions(open_ai_completions_request, ensure_full_sentences=ensure_full_sentences, chat_template=chat_template, tracking_id=tracking_id)
        print("The response of OperationsCompatibleWithOpenAIAPIsApi->generate_text_completions:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling OperationsCompatibleWithOpenAIAPIsApi->generate_text_completions: %s\n" % e)

Parameters

Name Type Description Notes
open_ai_completions_request OpenAICompletionsRequest
ensure_full_sentences bool Whether to generate full sentences only [optional] [default to False]
chat_template str Override chat template for prompt formatting [optional]
tracking_id str The tracking ID of the requested task [optional]

Return type

object

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful Response -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_model

object get_model(model_name)

Get Model

Get a specific model, similar to OpenAI's /v1/models/{model_id} endpoint

Example

  • OAuth Authentication (OAuth2PasswordBearer):
  • Api Key Authentication (APIKeyCookie):
import cms_client
from cms_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 = cms_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.

configuration.access_token = os.environ["ACCESS_TOKEN"]

# Configure API key authorization: APIKeyCookie
configuration.api_key['APIKeyCookie'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['APIKeyCookie'] = 'Bearer'

# Enter a context with an instance of the API client
with cms_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cms_client.OperationsCompatibleWithOpenAIAPIsApi(api_client)
    model_name = 'model_name_example' # str | 

    try:
        # Get Model
        api_response = api_instance.get_model(model_name)
        print("The response of OperationsCompatibleWithOpenAIAPIsApi->get_model:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling OperationsCompatibleWithOpenAIAPIsApi->get_model: %s\n" % e)

Parameters

Name Type Description Notes
model_name str

Return type

object

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful Response -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

list_models

object list_models()

List Models

List available models, similar to OpenAI's /v1/models endpoint

Example

  • OAuth Authentication (OAuth2PasswordBearer):
  • Api Key Authentication (APIKeyCookie):
import cms_client
from cms_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 = cms_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.

configuration.access_token = os.environ["ACCESS_TOKEN"]

# Configure API key authorization: APIKeyCookie
configuration.api_key['APIKeyCookie'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['APIKeyCookie'] = 'Bearer'

# Enter a context with an instance of the API client
with cms_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cms_client.OperationsCompatibleWithOpenAIAPIsApi(api_client)

    try:
        # List Models
        api_response = api_instance.list_models()
        print("The response of OperationsCompatibleWithOpenAIAPIsApi->list_models:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling OperationsCompatibleWithOpenAIAPIsApi->list_models: %s\n" % e)

Parameters

This endpoint does not need any parameter.

Return type

object

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful Response -

[Back to top] [Back to API list] [Back to Model list] [Back to README]