mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
* Updates endpoint from v1/completions to v1/chat/completions * Add SharpTokens as a library to calculate input token usage * Subtract input tokens from max_tokens to ensure the API tokens don't exceed the max specified * Add Chat history support since this API supports it * Add a personality prompt to tweak the way the bot behaves * Add a min_tokens config to increase the quality of chat messages when history is enabled * Adjust the response function to throw an exception so that a null message isn't added to the list.
46 lines
1005 B
C#
46 lines
1005 B
C#
#nullable disable
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace NadekoBot.Modules.Games.Common.ChatterBot;
|
|
|
|
public class Gpt3Response
|
|
{
|
|
[JsonPropertyName("choices")]
|
|
public Choice[] Choices { get; set; }
|
|
}
|
|
|
|
public class Choice
|
|
{
|
|
[JsonPropertyName("message")]
|
|
public Message Message { get; init; }
|
|
}
|
|
|
|
public class Message {
|
|
[JsonPropertyName("content")]
|
|
public string Content { get; init; }
|
|
}
|
|
|
|
public class Gpt3ApiRequest
|
|
{
|
|
[JsonPropertyName("model")]
|
|
public string Model { get; init; }
|
|
|
|
[JsonPropertyName("messages")]
|
|
public List<GPTMessage> Messages { get; init; }
|
|
|
|
[JsonPropertyName("temperature")]
|
|
public int Temperature { get; init; }
|
|
|
|
[JsonPropertyName("max_tokens")]
|
|
public int MaxTokens { get; init; }
|
|
}
|
|
|
|
public class GPTMessage
|
|
{
|
|
[JsonPropertyName("role")]
|
|
public string Role {get; init;}
|
|
[JsonPropertyName("content")]
|
|
public string Content {get; init;}
|
|
[JsonPropertyName("name")]
|
|
public string Name {get; init;}
|
|
} |