mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
Update GPT ChatterBot
* 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.
This commit is contained in:
@@ -11,7 +11,13 @@ public class Gpt3Response
|
||||
|
||||
public class Choice
|
||||
{
|
||||
public string Text { get; set; }
|
||||
[JsonPropertyName("message")]
|
||||
public Message Message { get; init; }
|
||||
}
|
||||
|
||||
public class Message {
|
||||
[JsonPropertyName("content")]
|
||||
public string Content { get; init; }
|
||||
}
|
||||
|
||||
public class Gpt3ApiRequest
|
||||
@@ -19,12 +25,22 @@ public class Gpt3ApiRequest
|
||||
[JsonPropertyName("model")]
|
||||
public string Model { get; init; }
|
||||
|
||||
[JsonPropertyName("prompt")]
|
||||
public string Prompt { 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;}
|
||||
}
|
Reference in New Issue
Block a user