-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9897812
Showing
68 changed files
with
1,638 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TavernAICardLib", "TavernAICardLib\TavernAICardLib.csproj", "{49C506A4-569E-4D61-8B57-70F54918A92F}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TavernAICardLibTest", "TavernAICardLibTest\TavernAICardLibTest.csproj", "{85FD33D4-5E93-4A30-AC31-662E04139EAD}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{49C506A4-569E-4D61-8B57-70F54918A92F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{49C506A4-569E-4D61-8B57-70F54918A92F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{49C506A4-569E-4D61-8B57-70F54918A92F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{49C506A4-569E-4D61-8B57-70F54918A92F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{85FD33D4-5E93-4A30-AC31-662E04139EAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{85FD33D4-5E93-4A30-AC31-662E04139EAD}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{85FD33D4-5E93-4A30-AC31-662E04139EAD}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{85FD33D4-5E93-4A30-AC31-662E04139EAD}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
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,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="MetadataExtractor" Version="2.8.0" /> | ||
<PackageReference Include="System.Drawing.Common" Version="7.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,81 @@ | ||
using System.Drawing; | ||
using System.Drawing.Imaging; | ||
using System.Text; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
using MetadataExtractor; | ||
|
||
namespace TavernAICardLib; | ||
|
||
public class TavernAiCard | ||
{ | ||
public Image image; | ||
|
||
|
||
// Card Fields: | ||
[JsonPropertyName("alternate_greetings")] public string[] alternateGreetings { get; set; } | ||
[JsonPropertyName("avatar")] public string avatar { get; set; } | ||
[JsonPropertyName("character_version")] public string characterVersion { get; set; } | ||
[JsonPropertyName("creator")] public string creator { get; set; } | ||
[JsonPropertyName("creator_notes")] public string creatorNotes { get; set; } | ||
[JsonPropertyName("description")] public string description { get; set; } | ||
[JsonPropertyName("mes_example")] public string messageExample { get; set; } | ||
[JsonPropertyName("name")] public string name { get; set; } | ||
[JsonPropertyName("personality")] public string personality { get; set; } | ||
[JsonPropertyName("post_history_instructions")] public string postHistoryInstructions { get; set; } | ||
[JsonPropertyName("scenario")] public string scenario { get; set; } | ||
[JsonPropertyName("system_prompt")] public string systemPrompt { get; set; } | ||
[JsonPropertyName("tags")] public string[] tags { get; set; } | ||
|
||
public TavernAiCard(Image image) | ||
{ | ||
this.image = image; | ||
} | ||
|
||
private static Dictionary<string[], CardLoader> FilePathEndsWith = new Dictionary<string[], CardLoader>() | ||
{ | ||
{new []{".png", ".webp", ".jpg", ".jpeg"}, new ImageCardLoader()}, | ||
}; | ||
|
||
public static TavernAiCard? Load(string filePath) | ||
{ | ||
foreach (var key in FilePathEndsWith.Keys) | ||
foreach (var end in key) | ||
if (filePath.ToLower().EndsWith(end)) | ||
return FilePathEndsWith[key].Load(filePath); | ||
|
||
return null; | ||
} | ||
} | ||
|
||
public abstract class CardLoader | ||
{ | ||
public abstract TavernAiCard Load(string filePath); | ||
} | ||
|
||
public class ImageCardLoader : CardLoader | ||
{ | ||
public override TavernAiCard Load(string filePath) | ||
{ | ||
Image image = new Bitmap(filePath); | ||
var directories = ImageMetadataReader.ReadMetadata(filePath); | ||
foreach (var dir in directories) | ||
{ | ||
foreach (var tag in dir.Tags) | ||
{ | ||
string[]? splitDesc = tag.Description?.Split(": "); | ||
if (splitDesc != null && splitDesc[0] == "chara") | ||
{ | ||
string jsonData = Encoding.ASCII.GetString(Convert.FromBase64String(splitDesc[1])); | ||
TavernAiCard? card = JsonSerializer.Deserialize<TavernAiCard>(jsonData); | ||
if (card != null) | ||
{ | ||
card.image = image; | ||
return card; | ||
} | ||
} | ||
} | ||
} | ||
return new TavernAiCard(image); | ||
} | ||
} |
139 changes: 139 additions & 0 deletions
139
TavernAICardLib/bin/Debug/net6.0/TavernAICardLib.deps.json
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,139 @@ | ||
{ | ||
"runtimeTarget": { | ||
"name": ".NETCoreApp,Version=v6.0", | ||
"signature": "" | ||
}, | ||
"compilationOptions": {}, | ||
"targets": { | ||
".NETCoreApp,Version=v6.0": { | ||
"TavernAICardLib/1.0.0": { | ||
"dependencies": { | ||
"MetadataExtractor": "2.8.0", | ||
"System.Drawing.Common": "7.0.0" | ||
}, | ||
"runtime": { | ||
"TavernAICardLib.dll": {} | ||
} | ||
}, | ||
"MetadataExtractor/2.8.0": { | ||
"dependencies": { | ||
"System.Text.Encoding.CodePages": "4.5.1", | ||
"XmpCore": "6.1.10.1" | ||
}, | ||
"runtime": { | ||
"lib/netstandard2.0/MetadataExtractor.dll": { | ||
"assemblyVersion": "2.8.0.0", | ||
"fileVersion": "2.8.0.0" | ||
} | ||
} | ||
}, | ||
"Microsoft.NETCore.Platforms/2.1.2": {}, | ||
"Microsoft.Win32.SystemEvents/7.0.0": { | ||
"runtime": { | ||
"lib/net6.0/Microsoft.Win32.SystemEvents.dll": { | ||
"assemblyVersion": "7.0.0.0", | ||
"fileVersion": "7.0.22.51805" | ||
} | ||
}, | ||
"runtimeTargets": { | ||
"runtimes/win/lib/net6.0/Microsoft.Win32.SystemEvents.dll": { | ||
"rid": "win", | ||
"assetType": "runtime", | ||
"assemblyVersion": "7.0.0.0", | ||
"fileVersion": "7.0.22.51805" | ||
} | ||
} | ||
}, | ||
"System.Drawing.Common/7.0.0": { | ||
"dependencies": { | ||
"Microsoft.Win32.SystemEvents": "7.0.0" | ||
}, | ||
"runtime": { | ||
"lib/net6.0/System.Drawing.Common.dll": { | ||
"assemblyVersion": "7.0.0.0", | ||
"fileVersion": "7.0.22.51805" | ||
} | ||
}, | ||
"runtimeTargets": { | ||
"runtimes/win/lib/net6.0/System.Drawing.Common.dll": { | ||
"rid": "win", | ||
"assetType": "runtime", | ||
"assemblyVersion": "7.0.0.0", | ||
"fileVersion": "7.0.22.51805" | ||
} | ||
} | ||
}, | ||
"System.Runtime.CompilerServices.Unsafe/4.5.2": {}, | ||
"System.Text.Encoding.CodePages/4.5.1": { | ||
"dependencies": { | ||
"Microsoft.NETCore.Platforms": "2.1.2", | ||
"System.Runtime.CompilerServices.Unsafe": "4.5.2" | ||
} | ||
}, | ||
"XmpCore/6.1.10.1": { | ||
"runtime": { | ||
"lib/netstandard2.0/XmpCore.dll": { | ||
"assemblyVersion": "6.1.10.1", | ||
"fileVersion": "6.1.10.1" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"libraries": { | ||
"TavernAICardLib/1.0.0": { | ||
"type": "project", | ||
"serviceable": false, | ||
"sha512": "" | ||
}, | ||
"MetadataExtractor/2.8.0": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-p4sa1yRUZNU2S4febP3ewmM524QDZ7qSM+PamR7vKLThlEDM1Wz4VBxO48Nk31uakUVUQ7az0ULkOyt31i+q0Q==", | ||
"path": "metadataextractor/2.8.0", | ||
"hashPath": "metadataextractor.2.8.0.nupkg.sha512" | ||
}, | ||
"Microsoft.NETCore.Platforms/2.1.2": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-mOJy3M0UN+LUG21dLGMxaWZEP6xYpQEpLuvuEQBaownaX4YuhH6NmNUlN9si+vNkAS6dwJ//N1O4DmLf2CikVg==", | ||
"path": "microsoft.netcore.platforms/2.1.2", | ||
"hashPath": "microsoft.netcore.platforms.2.1.2.nupkg.sha512" | ||
}, | ||
"Microsoft.Win32.SystemEvents/7.0.0": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-2nXPrhdAyAzir0gLl8Yy8S5Mnm/uBSQQA7jEsILOS1MTyS7DbmV1NgViMtvV1sfCD1ebITpNwb1NIinKeJgUVQ==", | ||
"path": "microsoft.win32.systemevents/7.0.0", | ||
"hashPath": "microsoft.win32.systemevents.7.0.0.nupkg.sha512" | ||
}, | ||
"System.Drawing.Common/7.0.0": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-KIX+oBU38pxkKPxvLcLfIkOV5Ien8ReN78wro7OF5/erwcmortzeFx+iBswlh2Vz6gVne0khocQudGwaO1Ey6A==", | ||
"path": "system.drawing.common/7.0.0", | ||
"hashPath": "system.drawing.common.7.0.0.nupkg.sha512" | ||
}, | ||
"System.Runtime.CompilerServices.Unsafe/4.5.2": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-wprSFgext8cwqymChhrBLu62LMg/1u92bU+VOwyfBimSPVFXtsNqEWC92Pf9ofzJFlk4IHmJA75EDJn1b2goAQ==", | ||
"path": "system.runtime.compilerservices.unsafe/4.5.2", | ||
"hashPath": "system.runtime.compilerservices.unsafe.4.5.2.nupkg.sha512" | ||
}, | ||
"System.Text.Encoding.CodePages/4.5.1": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-4J2JQXbftjPMppIHJ7IC+VXQ9XfEagN92vZZNoG12i+zReYlim5dMoXFC1Zzg7tsnKDM7JPo5bYfFK4Jheq44w==", | ||
"path": "system.text.encoding.codepages/4.5.1", | ||
"hashPath": "system.text.encoding.codepages.4.5.1.nupkg.sha512" | ||
}, | ||
"XmpCore/6.1.10.1": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-/Tp2/e39e7z8hLtS4TXt0FNNZHbf5yNFfHS0/59soXlgOzZlyRZivvzWpvujyaWkTWWgecp/1nHxkuc5vntn7A==", | ||
"path": "xmpcore/6.1.10.1", | ||
"hashPath": "xmpcore.6.1.10.1.nupkg.sha512" | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions
4
TavernAICardLib/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs
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,4 @@ | ||
// <autogenerated /> | ||
using System; | ||
using System.Reflection; | ||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] |
22 changes: 22 additions & 0 deletions
22
TavernAICardLib/obj/Debug/net6.0/TavernAICardLib.AssemblyInfo.cs
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,22 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
using System; | ||
using System.Reflection; | ||
|
||
[assembly: System.Reflection.AssemblyCompanyAttribute("TavernAICardLib")] | ||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] | ||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] | ||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] | ||
[assembly: System.Reflection.AssemblyProductAttribute("TavernAICardLib")] | ||
[assembly: System.Reflection.AssemblyTitleAttribute("TavernAICardLib")] | ||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] | ||
|
||
// Generated by the MSBuild WriteCodeFragment class. | ||
|
1 change: 1 addition & 0 deletions
1
TavernAICardLib/obj/Debug/net6.0/TavernAICardLib.AssemblyInfoInputs.cache
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 @@ | ||
ee66f1ad3396ee26634314a4d79a89296e9cb8f1 |
10 changes: 10 additions & 0 deletions
10
TavernAICardLib/obj/Debug/net6.0/TavernAICardLib.GeneratedMSBuildEditorConfig.editorconfig
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,10 @@ | ||
is_global = true | ||
build_property.TargetFramework = net6.0 | ||
build_property.TargetPlatformMinVersion = | ||
build_property.UsingMicrosoftNETSdkWeb = | ||
build_property.ProjectTypeGuids = | ||
build_property.InvariantGlobalization = | ||
build_property.PlatformNeutralAssembly = | ||
build_property._SupportedPlatformList = Linux,macOS,Windows | ||
build_property.RootNamespace = TavernAICardLib | ||
build_property.ProjectDir = A:\RiderProjects\TavernAICardLib\TavernAICardLib\ |
8 changes: 8 additions & 0 deletions
8
TavernAICardLib/obj/Debug/net6.0/TavernAICardLib.GlobalUsings.g.cs
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,8 @@ | ||
// <auto-generated/> | ||
global using global::System; | ||
global using global::System.Collections.Generic; | ||
global using global::System.IO; | ||
global using global::System.Linq; | ||
global using global::System.Net.Http; | ||
global using global::System.Threading; | ||
global using global::System.Threading.Tasks; |
Binary file not shown.
Binary file added
BIN
+73.5 KB
TavernAICardLib/obj/Debug/net6.0/TavernAICardLib.csproj.AssemblyReference.cache
Binary file not shown.
1 change: 1 addition & 0 deletions
1
TavernAICardLib/obj/Debug/net6.0/TavernAICardLib.csproj.CoreCompileInputs.cache
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 @@ | ||
b7ca3ac241c91568ea292791729bcf72fb466699 |
12 changes: 12 additions & 0 deletions
12
TavernAICardLib/obj/Debug/net6.0/TavernAICardLib.csproj.FileListAbsolute.txt
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,12 @@ | ||
A:\RiderProjects\TavernAICardLib\TavernAICardLib\bin\Debug\net6.0\TavernAICardLib.deps.json | ||
A:\RiderProjects\TavernAICardLib\TavernAICardLib\bin\Debug\net6.0\TavernAICardLib.dll | ||
A:\RiderProjects\TavernAICardLib\TavernAICardLib\bin\Debug\net6.0\ref\TavernAICardLib.dll | ||
A:\RiderProjects\TavernAICardLib\TavernAICardLib\bin\Debug\net6.0\TavernAICardLib.pdb | ||
A:\RiderProjects\TavernAICardLib\TavernAICardLib\obj\Debug\net6.0\TavernAICardLib.csproj.AssemblyReference.cache | ||
A:\RiderProjects\TavernAICardLib\TavernAICardLib\obj\Debug\net6.0\TavernAICardLib.GeneratedMSBuildEditorConfig.editorconfig | ||
A:\RiderProjects\TavernAICardLib\TavernAICardLib\obj\Debug\net6.0\TavernAICardLib.AssemblyInfoInputs.cache | ||
A:\RiderProjects\TavernAICardLib\TavernAICardLib\obj\Debug\net6.0\TavernAICardLib.AssemblyInfo.cs | ||
A:\RiderProjects\TavernAICardLib\TavernAICardLib\obj\Debug\net6.0\TavernAICardLib.csproj.CoreCompileInputs.cache | ||
A:\RiderProjects\TavernAICardLib\TavernAICardLib\obj\Debug\net6.0\TavernAICardLib.dll | ||
A:\RiderProjects\TavernAICardLib\TavernAICardLib\obj\Debug\net6.0\ref\TavernAICardLib.dll | ||
A:\RiderProjects\TavernAICardLib\TavernAICardLib\obj\Debug\net6.0\TavernAICardLib.pdb |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.