okai
Version:
AI-powered code generation tool for ServiceStack Apps. Generate TypeScript data models, C# APIs, migrations, and UI components from natural language prompts using LLMs.
287 lines (286 loc) • 17.8 kB
JavaScript
/* Options:
Date: 2024-11-29 17:33:02
Version: 8.53
Tip: To override a DTO option, remove "//" prefix before updating
BaseUrl: https://openai.servicestack.net
//GlobalNamespace:
//MakePropertiesOptional: False
//AddServiceStackTypes: True
//AddResponseStatus: False
//AddImplicitVersion:
//AddDescriptionAsComments: True
IncludeTypes: OpenAiChatCompletion.*
//ExcludeTypes:
//DefaultImports:
*/
/** @description The tool calls generated by the model, such as function calls. */
// @Api(Description="The tool calls generated by the model, such as function calls.")
// @DataContract
export class ToolCall {
/** @description The ID of the tool call. */
// @DataMember(Name="id")
// @ApiMember(Description="The ID of the tool call.")
id;
/** @description The type of the tool. Currently, only `function` is supported. */
// @DataMember(Name="type")
// @ApiMember(Description="The type of the tool. Currently, only `function` is supported.")
type;
/** @description The function that the model called. */
// @DataMember(Name="function")
// @ApiMember(Description="The function that the model called.")
function;
constructor(init) { Object.assign(this, init); }
}
/** @description A list of messages comprising the conversation so far. */
// @Api(Description="A list of messages comprising the conversation so far.")
// @DataContract
export class OpenAiMessage {
/** @description The contents of the message. */
// @DataMember(Name="content")
// @ApiMember(Description="The contents of the message.")
content;
/** @description The role of the author of this message. Valid values are `system`, `user`, `assistant` and `tool`. */
// @DataMember(Name="role")
// @ApiMember(Description="The role of the author of this message. Valid values are `system`, `user`, `assistant` and `tool`.")
role;
/** @description An optional name for the participant. Provides the model information to differentiate between participants of the same role. */
// @DataMember(Name="name")
// @ApiMember(Description="An optional name for the participant. Provides the model information to differentiate between participants of the same role.")
name;
/** @description The tool calls generated by the model, such as function calls. */
// @DataMember(Name="tool_calls")
// @ApiMember(Description="The tool calls generated by the model, such as function calls.")
tool_calls;
/** @description Tool call that this message is responding to. */
// @DataMember(Name="tool_call_id")
// @ApiMember(Description="Tool call that this message is responding to.")
tool_call_id;
constructor(init) { Object.assign(this, init); }
}
export var ResponseFormat;
(function (ResponseFormat) {
ResponseFormat["Text"] = "text";
ResponseFormat["JsonObject"] = "json_object";
})(ResponseFormat || (ResponseFormat = {}));
// @DataContract
export class OpenAiResponseFormat {
/** @description An object specifying the format that the model must output. Compatible with GPT-4 Turbo and all GPT-3.5 Turbo models newer than gpt-3.5-turbo-1106. */
// @DataMember(Name="response_format")
// @ApiMember(Description="An object specifying the format that the model must output. Compatible with GPT-4 Turbo and all GPT-3.5 Turbo models newer than gpt-3.5-turbo-1106.")
response_format;
constructor(init) { Object.assign(this, init); }
}
export var OpenAiToolType;
(function (OpenAiToolType) {
OpenAiToolType["Function"] = "function";
})(OpenAiToolType || (OpenAiToolType = {}));
// @DataContract
export class OpenAiTools {
/** @description The type of the tool. Currently, only function is supported. */
// @DataMember(Name="type")
// @ApiMember(Description="The type of the tool. Currently, only function is supported.")
type;
constructor(init) { Object.assign(this, init); }
}
/** @description Given a list of messages comprising a conversation, the model will return a response. */
// @Api(Description="Given a list of messages comprising a conversation, the model will return a response.")
// @DataContract
export class OpenAiChat {
/** @description A list of messages comprising the conversation so far. */
// @DataMember(Name="messages")
// @ApiMember(Description="A list of messages comprising the conversation so far.")
messages = [];
/** @description ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API */
// @DataMember(Name="model")
// @ApiMember(Description="ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API")
model;
/** @description Number between `-2.0` and `2.0`. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. */
// @DataMember(Name="frequency_penalty")
// @ApiMember(Description="Number between `-2.0` and `2.0`. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.")
frequency_penalty;
/** @description Modify the likelihood of specified tokens appearing in the completion. */
// @DataMember(Name="logit_bias")
// @ApiMember(Description="Modify the likelihood of specified tokens appearing in the completion.")
logit_bias;
/** @description Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message. */
// @DataMember(Name="logprobs")
// @ApiMember(Description="Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message.")
logprobs;
/** @description An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used. */
// @DataMember(Name="top_logprobs")
// @ApiMember(Description="An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used.")
top_logprobs;
/** @description The maximum number of tokens that can be generated in the chat completion. */
// @DataMember(Name="max_tokens")
// @ApiMember(Description="The maximum number of tokens that can be generated in the chat completion.")
max_tokens;
/** @description How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. */
// @DataMember(Name="n")
// @ApiMember(Description="How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs.")
n;
/** @description Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. */
// @DataMember(Name="presence_penalty")
// @ApiMember(Description="Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.")
presence_penalty;
/** @description An object specifying the format that the model must output. Compatible with GPT-4 Turbo and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. Setting Type to ResponseFormat.JsonObject enables JSON mode, which guarantees the message the model generates is valid JSON. */
// @DataMember(Name="response_format")
// @ApiMember(Description="An object specifying the format that the model must output. Compatible with GPT-4 Turbo and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. Setting Type to ResponseFormat.JsonObject enables JSON mode, which guarantees the message the model generates is valid JSON.")
response_format;
/** @description This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed, and you should refer to the system_fingerprint response parameter to monitor changes in the backend. */
// @DataMember(Name="seed")
// @ApiMember(Description="This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed, and you should refer to the system_fingerprint response parameter to monitor changes in the backend.")
seed;
/** @description Up to 4 sequences where the API will stop generating further tokens. */
// @DataMember(Name="stop")
// @ApiMember(Description="Up to 4 sequences where the API will stop generating further tokens.")
stop;
/** @description If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a `data: [DONE]` message. */
// @DataMember(Name="stream")
// @ApiMember(Description="If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a `data: [DONE]` message.")
stream;
/** @description What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. */
// @DataMember(Name="temperature")
// @ApiMember(Description="What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.")
temperature;
/** @description An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. */
// @DataMember(Name="top_p")
// @ApiMember(Description="An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.")
top_p;
/** @description A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. */
// @DataMember(Name="tools")
// @ApiMember(Description="A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.")
tools;
/** @description A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. */
// @DataMember(Name="user")
// @ApiMember(Description="A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.")
user;
constructor(init) { Object.assign(this, init); }
}
// @DataContract
export class ResponseError {
// @DataMember(Order=1)
errorCode;
// @DataMember(Order=2)
fieldName;
// @DataMember(Order=3)
message;
// @DataMember(Order=4)
meta;
constructor(init) { Object.assign(this, init); }
}
// @DataContract
export class ResponseStatus {
// @DataMember(Order=1)
errorCode;
// @DataMember(Order=2)
message;
// @DataMember(Order=3)
stackTrace;
// @DataMember(Order=4)
errors;
// @DataMember(Order=5)
meta;
constructor(init) { Object.assign(this, init); }
}
// @DataContract
export class ChoiceMessage {
/** @description The contents of the message. */
// @DataMember(Name="content")
// @ApiMember(Description="The contents of the message.")
content;
/** @description The tool calls generated by the model, such as function calls. */
// @DataMember(Name="tool_calls")
// @ApiMember(Description="The tool calls generated by the model, such as function calls.")
tool_calls;
/** @description The role of the author of this message. */
// @DataMember(Name="role")
// @ApiMember(Description="The role of the author of this message.")
role;
constructor(init) { Object.assign(this, init); }
}
export class Choice {
/** @description The reason the model stopped generating tokens. This will be stop if the model hit a natural stop point or a provided stop sequence, length if the maximum number of tokens specified in the request was reached, content_filter if content was omitted due to a flag from our content filters, tool_calls if the model called a tool */
// @DataMember(Name="finish_reason")
// @ApiMember(Description="The reason the model stopped generating tokens. This will be stop if the model hit a natural stop point or a provided stop sequence, length if the maximum number of tokens specified in the request was reached, content_filter if content was omitted due to a flag from our content filters, tool_calls if the model called a tool")
finish_reason;
/** @description The index of the choice in the list of choices. */
// @DataMember(Name="index")
// @ApiMember(Description="The index of the choice in the list of choices.")
index;
/** @description A chat completion message generated by the model. */
// @DataMember(Name="message")
// @ApiMember(Description="A chat completion message generated by the model.")
message;
constructor(init) { Object.assign(this, init); }
}
/** @description Usage statistics for the completion request. */
// @Api(Description="Usage statistics for the completion request.")
// @DataContract
export class OpenAiUsage {
/** @description Number of tokens in the generated completion. */
// @DataMember(Name="completion_tokens")
// @ApiMember(Description="Number of tokens in the generated completion.")
completion_tokens;
/** @description Number of tokens in the prompt. */
// @DataMember(Name="prompt_tokens")
// @ApiMember(Description="Number of tokens in the prompt.")
prompt_tokens;
/** @description Total number of tokens used in the request (prompt + completion). */
// @DataMember(Name="total_tokens")
// @ApiMember(Description="Total number of tokens used in the request (prompt + completion).")
total_tokens;
constructor(init) { Object.assign(this, init); }
}
// @DataContract
export class OpenAiChatResponse {
/** @description A unique identifier for the chat completion. */
// @DataMember(Name="id")
// @ApiMember(Description="A unique identifier for the chat completion.")
id;
/** @description A list of chat completion choices. Can be more than one if n is greater than 1. */
// @DataMember(Name="choices")
// @ApiMember(Description="A list of chat completion choices. Can be more than one if n is greater than 1.")
choices = [];
/** @description The Unix timestamp (in seconds) of when the chat completion was created. */
// @DataMember(Name="created")
// @ApiMember(Description="The Unix timestamp (in seconds) of when the chat completion was created.")
created;
/** @description The model used for the chat completion. */
// @DataMember(Name="model")
// @ApiMember(Description="The model used for the chat completion.")
model;
/** @description This fingerprint represents the backend configuration that the model runs with. */
// @DataMember(Name="system_fingerprint")
// @ApiMember(Description="This fingerprint represents the backend configuration that the model runs with.")
system_fingerprint;
/** @description The object type, which is always chat.completion. */
// @DataMember(Name="object")
// @ApiMember(Description="The object type, which is always chat.completion.")
object;
/** @description Usage statistics for the completion request. */
// @DataMember(Name="usage")
// @ApiMember(Description="Usage statistics for the completion request.")
usage;
// @DataMember(Name="responseStatus")
responseStatus;
constructor(init) { Object.assign(this, init); }
}
/** @description Given a list of messages comprising a conversation, the model will return a response. */
// @Route("/v1/chat/completions", "POST")
// @Api(Description="Given a list of messages comprising a conversation, the model will return a response.")
export class OpenAiChatCompletion extends OpenAiChat {
/** @description Provide a unique identifier to track requests */
// @ApiMember(Description="Provide a unique identifier to track requests")
refId;
/** @description Specify which AI Provider to use */
// @ApiMember(Description="Specify which AI Provider to use")
provider;
/** @description Categorize like requests under a common group */
// @ApiMember(Description="Categorize like requests under a common group")
tag;
constructor(init) { super(init); Object.assign(this, init); }
getTypeName() { return 'OpenAiChatCompletion'; }
getMethod() { return 'POST'; }
createResponse() { return new OpenAiChatResponse(); }
}
//# sourceMappingURL=openai.js.map