Skip to content

Commit

Permalink
🚀 [Code] Updated ChatGPT in .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmonettelli committed Jan 9, 2024
1 parent 9cabc7a commit e6d57c8
Show file tree
Hide file tree
Showing 30 changed files with 775 additions and 224 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: [danielmonettelli]
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "nuget"
directory: "/ChatGPT/"
schedule:
interval: "daily"
42 changes: 21 additions & 21 deletions .github/workflows/mobile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup .NET v7.0
uses: actions/setup-dotnet@v3
- name: Setup .NET v8.0
uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: "7.0.x"
dotnet-version: "8.0.x"

- name: Install .NET MAUI Workload
run: |
Expand All @@ -44,18 +44,18 @@ jobs:
- name: Build Android App
run: |
dotnet build ./ChatGPT -f net7.0-android
dotnet build ./ChatGPT -f net8.0-android
Build_iOS:
runs-on: macos-12
runs-on: macos-13

steps:
- uses: actions/checkout@v3

- name: Setup .NET v7.0
uses: actions/setup-dotnet@v3
- name: Setup .NET v8.0
uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: "7.0.x"
dotnet-version: "8.0.x"

- name: Install .NET MAUI Workload
run: |
Expand All @@ -66,24 +66,24 @@ jobs:
dotnet restore ./ChatGPT
- name: Install Xcode
uses: maxim-lobanov/setup-xcode@v1.5.1
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest
xcode-version: latest-stable

- name: Build iOS App
run: |
dotnet build ./ChatGPT -f net7.0-ios
dotnet build ./ChatGPT -f net8.0-ios
Build_MacCatalyst:
runs-on: macos-12
runs-on: macos-13

steps:
- uses: actions/checkout@v3

- name: Setup .NET v7.0
uses: actions/setup-dotnet@v3
- name: Setup .NET v8.0
uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: "7.0.x"
dotnet-version: "8.0.x"

- name: Install .NET MAUI Workload
run: |
Expand All @@ -94,13 +94,13 @@ jobs:
dotnet restore ./ChatGPT
- name: Install Xcode
uses: maxim-lobanov/setup-xcode@v1.5.1
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest
xcode-version: latest-stable

- name: Build macOS App
run: |
dotnet build ./ChatGPT -f net7.0-maccatalyst
dotnet build ./ChatGPT -f net8.0-maccatalyst
Build_Windows:
runs-on: windows-latest
Expand All @@ -113,10 +113,10 @@ jobs:
distribution: 'microsoft'
java-version: '11'

- name: Setup .NET v7.0
uses: actions/setup-dotnet@v3
- name: Setup .NET v8.0
uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: "7.0.x"
dotnet-version: "8.0.x"

- name: Install .NET MAUI Workload
run: |
Expand Down
1 change: 1 addition & 0 deletions ChatGPT/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Labels.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Expand Down
17 changes: 9 additions & 8 deletions ChatGPT/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
namespace ChatGPT;

public partial class App : Application
namespace ChatGPT
{
public App()
{
InitializeComponent();
public partial class App : Application
{
public App()
{
InitializeComponent();

MainPage = new AppShell();
}
MainPage = new AppShell();
}
}
}
3 changes: 3 additions & 0 deletions ChatGPT/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
x:Class="ChatGPT.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:ChatGPT"
xmlns:views="clr-namespace:ChatGPT.Views"
Title="ChatGPT"
Shell.FlyoutBehavior="Disabled">

<ShellContent
Title="Conversation"
ContentTemplate="{DataTemplate views:ConversationView}"
Route="ConversationPage" />

</Shell>
15 changes: 8 additions & 7 deletions ChatGPT/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
namespace ChatGPT;

public partial class AppShell : Shell
namespace ChatGPT
{
public AppShell()
{
InitializeComponent();
}
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
}
134 changes: 69 additions & 65 deletions ChatGPT/ChatGPT.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->

<!-- Note for MacCatalyst:
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->

<OutputType>Exe</OutputType>
<RootNamespace>ChatGPT</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<!-- Display name -->
<ApplicationTitle>ChatGPT</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.chatgpt</ApplicationId>
<ApplicationIdGuid>6757cb1e-1461-4665-abf6-24e10b9fc104</ApplicationIdGuid>
<ApplicationId>com.danielmonettelli.chatgpt</ApplicationId>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
Expand All @@ -30,65 +38,61 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#11A37F" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#11A37F" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<None Remove="Resources\Fonts\Mona-Sans-Bold.ttf" />
<None Remove="Resources\Fonts\Mona-Sans-Medium.ttf" />
<None Remove="Resources\Images\svg_brand.svg" />
<None Remove="Resources\Images\svg_brand_dark.svg" />
<None Remove="Resources\Images\svg_brand_light.svg" />
<None Remove="Resources\Images\svg_microphone.svg" />
<None Remove="Resources\Images\svg_mode_image.svg" />
<None Remove="Resources\Images\svg_mode_message.svg" />
<None Remove="Resources\Images\svg_send_message.svg" />
<None Remove="Resources\Images\svg_user.svg" />
<None Remove="Resources\Raw\emptychat_dark.json" />
<None Remove="Resources\Raw\emptychat_light.json" />
<None Remove="Resources\Raw\loading.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="5.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="SkiaSharp.Extended.UI.Maui" Version="2.0.0-preview.61" />
</ItemGroup>

<ItemGroup>
<Compile Update="Views\ConversationView.xaml.cs">
<DependentUpon>ConversationView.xaml</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<MauiXaml Update="Resources\Styles\Labels.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\ConversationView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Templates\BotMessageItemTemplate.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Templates\UserMessageItemTemplate.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#11A37F" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#11A37F" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<None Remove="Resources\Fonts\Mona-Sans-Bold.ttf" />
<None Remove="Resources\Fonts\Mona-Sans-Medium.ttf" />
<None Remove="Resources\Images\svg_bot.svg" />
<None Remove="Resources\Images\svg_brand_dark.svg" />
<None Remove="Resources\Images\svg_brand_light.svg" />
<None Remove="Resources\Images\svg_microphone.svg" />
<None Remove="Resources\Images\svg_mode_image.svg" />
<None Remove="Resources\Images\svg_mode_message.svg" />
<None Remove="Resources\Images\svg_send_message.svg" />
<None Remove="Resources\Images\svg_user.svg" />
<None Remove="Resources\raw\emptychat_dark.json" />
<None Remove="Resources\raw\emptychat_light.json" />
<None Remove="Resources\raw\loading.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="7.0.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="SkiaSharp.Extended.UI.Maui" Version="2.0.0-preview.86" />
</ItemGroup>

<ItemGroup>
<MauiXaml Update="Resources\Styles\Labels.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\ConversationView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Templates\BotMessageItemTemplate.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Templates\UserMessageItemTemplate.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>

</Project>
18 changes: 9 additions & 9 deletions ChatGPT/ChatGPT.sln
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31611.283
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChatGPT", "ChatGPT.csproj", "{A8A52DCB-72EA-4A12-AADA-F7BBC61EE537}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChatGPT", "ChatGPT.csproj", "{CEA4AB77-84CB-4662-A5B8-7D71182A5296}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A8A52DCB-72EA-4A12-AADA-F7BBC61EE537}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A8A52DCB-72EA-4A12-AADA-F7BBC61EE537}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8A52DCB-72EA-4A12-AADA-F7BBC61EE537}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{A8A52DCB-72EA-4A12-AADA-F7BBC61EE537}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8A52DCB-72EA-4A12-AADA-F7BBC61EE537}.Release|Any CPU.Build.0 = Release|Any CPU
{A8A52DCB-72EA-4A12-AADA-F7BBC61EE537}.Release|Any CPU.Deploy.0 = Release|Any CPU
{CEA4AB77-84CB-4662-A5B8-7D71182A5296}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CEA4AB77-84CB-4662-A5B8-7D71182A5296}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEA4AB77-84CB-4662-A5B8-7D71182A5296}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{CEA4AB77-84CB-4662-A5B8-7D71182A5296}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CEA4AB77-84CB-4662-A5B8-7D71182A5296}.Release|Any CPU.Build.0 = Release|Any CPU
{CEA4AB77-84CB-4662-A5B8-7D71182A5296}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
SolutionGuid = {B0B0D1C3-E4DF-4A6F-B3E3-67C9107DF77F}
EndGlobalSection
EndGlobal
14 changes: 7 additions & 7 deletions ChatGPT/Constants/APIConstants.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
namespace ChatGPT.Constants
{
public static class APIConstants
{
public const string OpenAIUrl = "https://api.openai.com/";
public const string OpenAIToken = "OPENAI_API_KEY_HERE";
public static class APIConstants
{
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/completions";
public const string OpenAIEndpoint_Generations = "v1/images/generations";
}
}
Loading

0 comments on commit e6d57c8

Please sign in to comment.