Skip to content

Latest commit

 

History

History
189 lines (151 loc) · 8.65 KB

File metadata and controls

189 lines (151 loc) · 8.65 KB

GenerateTextBasedOnTheInputPromptApi

All URIs are relative to http://localhost

Method HTTP request Description
generateText POST /generate Generate Text
generateTextStream POST /stream/generate Generate Text Stream

generateText

String generateText(body, maxTokens, temperature, topP, stopSequences, includeUsage, ensureFullSentences, chatTemplate, trackingId)

Generate Text

Generate text

Example

// Import classes:
import org.cms.client.ApiClient;
import org.cms.client.ApiException;
import org.cms.client.Configuration;
import org.cms.client.auth.*;
import org.cms.client.models.*;
import org.cms.client.api.GenerateTextBasedOnTheInputPromptApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("http://localhost");
    
    // Configure OAuth2 access token for authorization: OAuth2PasswordBearer
    OAuth OAuth2PasswordBearer = (OAuth) defaultClient.getAuthentication("OAuth2PasswordBearer");
    OAuth2PasswordBearer.setAccessToken("YOUR ACCESS TOKEN");

    // Configure API key authorization: APIKeyCookie
    ApiKeyAuth APIKeyCookie = (ApiKeyAuth) defaultClient.getAuthentication("APIKeyCookie");
    APIKeyCookie.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //APIKeyCookie.setApiKeyPrefix("Token");

    GenerateTextBasedOnTheInputPromptApi apiInstance = new GenerateTextBasedOnTheInputPromptApi(defaultClient);
    String body = "body_example"; // String | 
    Integer maxTokens = 512; // Integer | The maximum number of tokens to generate
    BigDecimal temperature = new BigDecimal("0.7"); // BigDecimal | The temperature of the generated text
    BigDecimal topP = new BigDecimal("0.9"); // BigDecimal | The Top-P value for nucleus sampling
    List<String> stopSequences = Arrays.asList(); // List<String> | The list of sequences used to stop the generation
    Boolean includeUsage = false; // Boolean | Whether to include token usage in the response
    Boolean ensureFullSentences = false; // Boolean | Whether to generate full sentences only
    String chatTemplate = "chatTemplate_example"; // String | Override chat template for prompt formatting
    String trackingId = "trackingId_example"; // String | The tracking ID of the requested task
    try {
      String result = apiInstance.generateText(body, maxTokens, temperature, topP, stopSequences, includeUsage, ensureFullSentences, chatTemplate, trackingId);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling GenerateTextBasedOnTheInputPromptApi#generateText");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
body String
maxTokens Integer The maximum number of tokens to generate [optional] [default to 512]
temperature BigDecimal The temperature of the generated text [optional] [default to 0.7]
topP BigDecimal The Top-P value for nucleus sampling [optional] [default to 0.9]
stopSequences List<String> The list of sequences used to stop the generation [optional]
includeUsage Boolean Whether to include token usage in the response [optional] [default to false]
ensureFullSentences Boolean Whether to generate full sentences only [optional] [default to false]
chatTemplate String Override chat template for prompt formatting [optional]
trackingId String The tracking ID of the requested task [optional]

Return type

String

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

  • Content-Type: text/plain
  • Accept: text/plain, application/json

HTTP response details

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

generateTextStream

generateTextStream(body, maxTokens, temperature, topP, stopSequences, includeUsage, ensureFullSentences, chatTemplate, trackingId)

Generate Text Stream

Generate a stream of texts

Example

// Import classes:
import org.cms.client.ApiClient;
import org.cms.client.ApiException;
import org.cms.client.Configuration;
import org.cms.client.auth.*;
import org.cms.client.models.*;
import org.cms.client.api.GenerateTextBasedOnTheInputPromptApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("http://localhost");
    
    // Configure OAuth2 access token for authorization: OAuth2PasswordBearer
    OAuth OAuth2PasswordBearer = (OAuth) defaultClient.getAuthentication("OAuth2PasswordBearer");
    OAuth2PasswordBearer.setAccessToken("YOUR ACCESS TOKEN");

    // Configure API key authorization: APIKeyCookie
    ApiKeyAuth APIKeyCookie = (ApiKeyAuth) defaultClient.getAuthentication("APIKeyCookie");
    APIKeyCookie.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //APIKeyCookie.setApiKeyPrefix("Token");

    GenerateTextBasedOnTheInputPromptApi apiInstance = new GenerateTextBasedOnTheInputPromptApi(defaultClient);
    String body = "body_example"; // String | 
    Integer maxTokens = 512; // Integer | The maximum number of tokens to generate
    BigDecimal temperature = new BigDecimal("0.7"); // BigDecimal | The temperature of the generated text
    BigDecimal topP = new BigDecimal("0.9"); // BigDecimal | The Top-P value for nucleus sampling
    List<String> stopSequences = Arrays.asList(); // List<String> | The list of sequences used to stop the generation
    Boolean includeUsage = false; // Boolean | Whether to include token usage in the response
    Boolean ensureFullSentences = false; // Boolean | Whether to generate full sentences only
    String chatTemplate = "chatTemplate_example"; // String | Override chat template for prompt formatting
    String trackingId = "trackingId_example"; // String | The tracking ID of the requested task
    try {
      apiInstance.generateTextStream(body, maxTokens, temperature, topP, stopSequences, includeUsage, ensureFullSentences, chatTemplate, trackingId);
    } catch (ApiException e) {
      System.err.println("Exception when calling GenerateTextBasedOnTheInputPromptApi#generateTextStream");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
body String
maxTokens Integer The maximum number of tokens to generate [optional] [default to 512]
temperature BigDecimal The temperature of the generated text [optional] [default to 0.7]
topP BigDecimal The Top-P value for nucleus sampling [optional] [default to 0.9]
stopSequences List<String> The list of sequences used to stop the generation [optional]
includeUsage Boolean Whether to include token usage in the response [optional] [default to false]
ensureFullSentences Boolean Whether to generate full sentences only [optional] [default to false]
chatTemplate String Override chat template for prompt formatting [optional]
trackingId String The tracking ID of the requested task [optional]

Return type

null (empty response body)

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

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

HTTP response details

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