Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created January 26, 2024 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/146500c6408d06fa09804ef4bb0cd229 to your computer and use it in GitHub Desktop.
Save bjoerntx/146500c6408d06fa09804ef4bb0cd229 to your computer and use it in GitHub Desktop.
namespace TXTextControl.OpenAI {
public class ChatGPTRequest
{
public string Text { get; set; }
public string Type { get; set; }
}
public class RequestMessage
{
[JsonPropertyName("role")]
public string Role { get; set; }
[JsonPropertyName("content")]
public string Content { get; set; }
}
public class Request
{
[JsonPropertyName("model")]
public string Model { get; set; } = "gpt-3.5-turbo";
[JsonPropertyName("max_tokens")]
public int MaxTokens { get; set; } = 100;
[JsonPropertyName("messages")]
public RequestMessage[] Messages { get; set; }
}
public class Response
{
[JsonPropertyName("id")]
public string Id { get; set; }
[JsonPropertyName("created")]
public int Created { get; set; }
[JsonPropertyName("model")]
public string Model { get; set; }
[JsonPropertyName("usage")]
public ResponseUsage Usage { get; set; }
[JsonPropertyName("choices")]
public ResponseChoice[] Choices { get; set; }
}
public class ResponseUsage
{
[JsonPropertyName("prompt_tokens")]
public int PromptTokens { get; set; }
[JsonPropertyName("completion_tokens")]
public int CompletionTokens { get; set; }
[JsonPropertyName("total_tokens")]
public int TotalTokens { get; set; }
}
public class ResponseChoice
{
[JsonPropertyName("message")]
public ResponseMessage Message { get; set; }
[JsonPropertyName("finish_reason")]
public string FinishReason { get; set; }
[JsonPropertyName("index")]
public int Index { get; set; }
}
public class ResponseMessage
{
[JsonPropertyName("role")]
public string Role { get; set; }
[JsonPropertyName("content")]
public string Content { get; set; }
}
public class ChatGPTResponse
{
public string Id { get; set; }
public Choice[] Choices { get; set; }
}
public class Choice
{
public string Text { get; set; }
public int Index { get; set; }
}
public class Constants
{
public static string OPENAI_API_KEY = "";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment