-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚀 [Code] Updated architecture to "Chat Completion"
- Loading branch information
1 parent
69def9b
commit 516774d
Showing
16 changed files
with
246 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
namespace ChatGPT.Constants | ||
namespace ChatGPT.Constants; | ||
|
||
public static class APIConstants | ||
{ | ||
public static class APIConstants | ||
{ | ||
public const string OpenAIUrl = "https://api.openai.com/"; | ||
public const string OpenAIToken = "OPENAI_API_KEY_HERE"; | ||
public const string OpenAIUrl = "https://api.openai.com/"; | ||
public const string OpenAIToken = "OPENAI_API_KEY_HERE"; | ||
|
||
public const string OpenAIEndpoint_Completions = "v1/completions"; | ||
public const string OpenAIEndpoint_Generations = "v1/images/generations"; | ||
} | ||
public const string OpenAIEndpoint_Completions = "v1/chat/completions"; | ||
public const string OpenAIEndpoint_Generations = "v1/images/generations"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
namespace ChatGPT.Models | ||
namespace ChatGPT.Models; | ||
|
||
public class Choice | ||
{ | ||
public class Choice | ||
{ | ||
public string Text { get; set; } | ||
public int Index { get; set; } | ||
} | ||
public Message Message { get; set; } | ||
} | ||
|
||
public class Message | ||
{ | ||
public string Role { get; set; } = "assistant"; | ||
|
||
public string Content { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace ChatGPT.Models | ||
namespace ChatGPT.Models; | ||
|
||
public class CompletionRequest | ||
{ | ||
public class CompletionRequest | ||
{ | ||
[JsonPropertyName("model")] | ||
public string Model { get; set; } = "gpt-3.5-turbo-instruct"; | ||
[JsonPropertyName("model")] | ||
public string Model { get; set; } | ||
|
||
[JsonPropertyName("prompt")] | ||
public string Prompt { get; set; } | ||
[JsonPropertyName("messages")] | ||
public List<MessageRequest> Messages { get; set; } | ||
} | ||
|
||
[JsonPropertyName("temperature")] | ||
public double Temperature { get; set; } = 0; | ||
public class MessageRequest | ||
{ | ||
[JsonPropertyName("role")] | ||
public string Role { get; set; } | ||
|
||
[JsonPropertyName("max_tokens")] | ||
public int MaxTokens { get; set; } = 100; | ||
} | ||
} | ||
[JsonPropertyName("content")] | ||
public string Content { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
namespace ChatGPT.Models | ||
namespace ChatGPT.Models; | ||
|
||
public class CompletionResponse | ||
{ | ||
public class CompletionResponse | ||
{ | ||
public string Id { get; set; } | ||
public List<Choice> Choices { get; set; } | ||
} | ||
public string Id { get; set; } | ||
|
||
public List<Choice> Choices { get; set; } | ||
|
||
public Usage Usage { get; set; } | ||
} | ||
|
||
public class Usage | ||
{ | ||
public int Prompt_Tokens { get; set; } = 9; | ||
|
||
public int Completion_Tokens { get; set; } = 12; | ||
|
||
public int Total_Tokens { get; set; } = 21; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
namespace ChatGPT.Models | ||
namespace ChatGPT.Models; | ||
|
||
public class GeneratedImage | ||
{ | ||
public class GeneratedImage | ||
{ | ||
public string Url { get; set; } | ||
} | ||
public string Url { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace ChatGPT.Models | ||
namespace ChatGPT.Models; | ||
|
||
public class GenerationRequest | ||
{ | ||
public class GenerationRequest | ||
{ | ||
[JsonPropertyName("prompt")] | ||
public string Prompt { get; set; } | ||
[JsonPropertyName("prompt")] | ||
public string Prompt { get; set; } | ||
|
||
[JsonPropertyName("n")] | ||
public int N { get; set; } = 1; | ||
[JsonPropertyName("n")] | ||
public int N { get; set; } = 1; | ||
|
||
[JsonPropertyName("size")] | ||
public string Size { get; set; } = "512x512"; | ||
} | ||
[JsonPropertyName("size")] | ||
public string Size { get; set; } = "512x512"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
namespace ChatGPT.Models | ||
namespace ChatGPT.Models; | ||
|
||
public class GenerationResponse | ||
{ | ||
public class GenerationResponse | ||
{ | ||
public List<GeneratedImage> Data { get; set; } | ||
} | ||
public List<GeneratedImage> Data { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace ChatGPT.Models; | ||
|
||
public class LocalMessage | ||
{ | ||
public string Text { get; set; } | ||
public bool IsUserMessage { get; set; } | ||
public bool IsTextActive { get; set; } | ||
public bool IsImageActive { get; set; } | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
namespace ChatGPT.Services | ||
namespace ChatGPT.Services; | ||
|
||
public interface IOpenAIService | ||
{ | ||
public interface IOpenAIService | ||
{ | ||
Task<string> AskQuestion(string query); | ||
Task<string> AskQuestion(string query); | ||
|
||
Task<string> CreateImage(string query); | ||
} | ||
Task<string> CreateImage(string query); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
|
||
namespace ChatGPT.ViewModels | ||
namespace ChatGPT.ViewModels; | ||
|
||
public partial class BaseViewModel : ObservableObject | ||
{ | ||
public partial class BaseViewModel : ObservableObject | ||
{ | ||
[ObservableProperty] | ||
bool isBusy; | ||
} | ||
[ObservableProperty] | ||
bool isBusy; | ||
} |
Oops, something went wrong.