All URIs are relative to http://localhost
| Method | HTTP request | Description |
|---|---|---|
| generate_text | POST /generate | Generate Text |
| generate_text_stream | POST /stream/generate | Generate Text Stream |
str generate_text(body, max_tokens=max_tokens, temperature=temperature, top_p=top_p, stop_sequences=stop_sequences, include_usage=include_usage, ensure_full_sentences=ensure_full_sentences, chat_template=chat_template, tracking_id=tracking_id)
Generate Text
Generate text
- 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.GenerateTextBasedOnTheInputPromptApi(api_client)
body = 'body_example' # str |
max_tokens = 512 # int | The maximum number of tokens to generate (optional) (default to 512)
temperature = 0.7 # float | The temperature of the generated text (optional) (default to 0.7)
top_p = 0.9 # float | The Top-P value for nucleus sampling (optional) (default to 0.9)
stop_sequences = [] # List[Optional[str]] | The list of sequences used to stop the generation (optional) (default to [])
include_usage = False # bool | Whether to include token usage in the response (optional) (default to False)
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
api_response = api_instance.generate_text(body, max_tokens=max_tokens, temperature=temperature, top_p=top_p, stop_sequences=stop_sequences, include_usage=include_usage, ensure_full_sentences=ensure_full_sentences, chat_template=chat_template, tracking_id=tracking_id)
print("The response of GenerateTextBasedOnTheInputPromptApi->generate_text:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling GenerateTextBasedOnTheInputPromptApi->generate_text: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| body | str | ||
| max_tokens | int | The maximum number of tokens to generate | [optional] [default to 512] |
| temperature | float | The temperature of the generated text | [optional] [default to 0.7] |
| top_p | float | The Top-P value for nucleus sampling | [optional] [default to 0.9] |
| stop_sequences | List[Optional[str]] | The list of sequences used to stop the generation | [optional] [default to []] |
| include_usage | bool | Whether to include token usage in the response | [optional] [default to False] |
| 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] |
str
OAuth2PasswordBearer, APIKeyCookie
- Content-Type: text/plain
- Accept: text/plain, application/json
| 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_stream(body, max_tokens=max_tokens, temperature=temperature, top_p=top_p, stop_sequences=stop_sequences, include_usage=include_usage, ensure_full_sentences=ensure_full_sentences, chat_template=chat_template, tracking_id=tracking_id)
Generate Text Stream
Generate a stream of texts
- 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.GenerateTextBasedOnTheInputPromptApi(api_client)
body = 'body_example' # str |
max_tokens = 512 # int | The maximum number of tokens to generate (optional) (default to 512)
temperature = 0.7 # float | The temperature of the generated text (optional) (default to 0.7)
top_p = 0.9 # float | The Top-P value for nucleus sampling (optional) (default to 0.9)
stop_sequences = [] # List[Optional[str]] | The list of sequences used to stop the generation (optional) (default to [])
include_usage = False # bool | Whether to include token usage in the response (optional) (default to False)
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 Stream
api_instance.generate_text_stream(body, max_tokens=max_tokens, temperature=temperature, top_p=top_p, stop_sequences=stop_sequences, include_usage=include_usage, ensure_full_sentences=ensure_full_sentences, chat_template=chat_template, tracking_id=tracking_id)
except Exception as e:
print("Exception when calling GenerateTextBasedOnTheInputPromptApi->generate_text_stream: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| body | str | ||
| max_tokens | int | The maximum number of tokens to generate | [optional] [default to 512] |
| temperature | float | The temperature of the generated text | [optional] [default to 0.7] |
| top_p | float | The Top-P value for nucleus sampling | [optional] [default to 0.9] |
| stop_sequences | List[Optional[str]] | The list of sequences used to stop the generation | [optional] [default to []] |
| include_usage | bool | Whether to include token usage in the response | [optional] [default to False] |
| 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] |
void (empty response body)
OAuth2PasswordBearer, APIKeyCookie
- Content-Type: text/plain
- Accept: application/json
| 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]