Skip to content

Commit

Permalink
First commit for chatGPT function calling
Browse files Browse the repository at this point in the history
  • Loading branch information
jsboige committed Dec 15, 2023
1 parent c6e4ccb commit 4510306
Show file tree
Hide file tree
Showing 17 changed files with 1,130 additions and 658 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="Betalgo.OpenAI" Version="7.4.2" />
<PackageReference Include="Betalgo.OpenAI.Utilities" Version="7.0.3" />
<PackageReference Include="CsvHelper" Version="30.0.1" />
<PackageReference Include="ExtendedXmlSerializer" Version="3.7.11" />
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="13.5.0" />
Expand Down
138 changes: 120 additions & 18 deletions Generation/Converters/Argumentum.AssetConverter/AssetConverterConfig.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using System.Xml.Serialization;
using Argumentum.AssetConverter.DatasetUpdater;
using Argumentum.AssetConverter.Dnn2sxc;
using Argumentum.AssetConverter.Mindmapper;
using OpenAI.ObjectModels;
using Spectre.Console;
using Spectre.Console.Json;
using Utf8Json;
Expand All @@ -31,7 +34,96 @@ public class AssetConverterConfig

public BatchImageConverterConfig BatchImageConverterConfig { get; set; } = new BatchImageConverterConfig();

public DatasetUpdaterConfig DatasetUpdaterConfig { get; set; } = new DatasetUpdaterConfig();
public List<DatasetUpdaterConfig> DatasetUpdaterConfigs { get; set; } = new List<DatasetUpdaterConfig>()
{
new DatasetUpdaterConfig()
{
Enabled = false,
SourceDataset = new DataSetInfo()
{
Name = "Argumentum - Virtues - Taxonomy",
ReleaseFilePath = "https://raw.githubusercontent.com/ArgumentumGames/Argumentum/master/Cards/Fallacies/Argumentum%20Virtues%20-%20Taxonomy.csv",
DebugFilePath = @"..\..\..\..\..\..\Cards\Fallacies\Argumentum Virtues - Taxonomy.csv",
},
FieldsToInclude = new List<string>()
{
"path",
"family_fr",
"subfamily_fr",
"subsubfamily_fr",
"title_fr",
"description_fr",
"remark_fr",
"link_fr"
},
FieldsToUpdate = new List<string>()
{
"title_fr",
"description_fr",
"remark_fr",
"link_fr"
},
PrimaryField = "path",
TargetPath = @".\Target\Datasets\Argumentum Virtues - Taxonomy.csv",
SystemPrompt = Resource1.VirtuesJsonPromptSystem,
AddPromptSample = true,
UserPrompt = Resource1.VirtuesJsonPromptSampleUser,
AssistantPrompt = Resource1.VirtuesJsonPromptSampleAssistant,
Model = Models.Gpt_4_1106_preview,
MaxTokensPerMinute = 70000,
DivisionMode = DivisionMode.SequentialChunks,
ChunkSize = 3,
UseFunctionCalling = false,
NbMessageCalls = 1,
SkipChunkNb = 0,
TakeChunkNb = 3,
MaxDegreeOfParallelismWebService = 2
},
new DatasetUpdaterConfig()
{
Enabled = true,
SourceDataset = new DataSetInfo()
{
Name = "Argumentum - Fallacies - Taxonomy",
ReleaseFilePath = "https://raw.githubusercontent.com/ArgumentumGames/Argumentum/master/Cards/Fallacies/Argumentum%20Fallacies%20-%20Taxonomy.csv",
DebugFilePath = @"..\..\..\..\..\..\Cards\Fallacies\Argumentum Fallacies - Taxonomy.csv",
},
FieldsToInclude = new List<string>()
{
"path",
//"Famille",
//"Sous-Famille",
//"Soussousfamille",
"text_fr",
"desc_fr",
"example_fr",
//"link_fr"
},
FieldsToUpdate = new List<string>()
{
//"path",
"text_fr",
"desc_fr",
"example_fr",
//"link_fr"
},
PrimaryField = "path",
TargetPath = @".\Target\Datasets\Argumentum Virtues - Taxonomy.csv",
SystemPrompt = Resource1.FallaciesJsonPromptSystem,
AddPromptSample = false,
UserPrompt = Resource1.FallaciesJsonPromptSampleUser,
AssistantPrompt = Resource1.FallaciesJsonPromptSampleAssistant,
Model = Models.Gpt_4_1106_preview,
MaxTokensPerMinute = 70000,
DivisionMode = DivisionMode.PKHierarchicalChar,
PKHierarchyLevel = 3,
UseFunctionCalling = true,
NbMessageCalls = 1,
SkipChunkNb = 0,
TakeChunkNb = 1,
MaxDegreeOfParallelismWebService = 2
}
};

public Dnn2sxcConfig Dnn2sxcConfig { get; set; } = new Dnn2sxcConfig();

Expand Down Expand Up @@ -91,7 +183,7 @@ public static AssetConverterConfig GetConfig(string path, out bool newConfig)
bool isInDebugMode = false;
#endif

public bool Apply()
public async Task<bool> Apply()
{
switch (Mode)
{
Expand All @@ -100,23 +192,33 @@ public bool Apply()
break;
case ConverterMode.WebBasedImageGeneration:
WebBasedGeneratorConfig.UseDebugParams = () => UseDebugParams;
WebBasedGeneratorConfig.Apply();
break;
case ConverterMode.Mindmapper:
MindMapCreatorConfig.Run(null);
break;
case ConverterMode.Dnn2sxc:
Dnn2sxcConfig.Apply();
break;
case ConverterMode.DatasetUpdater:
Task.Run(async () => await DatasetUpdaterConfig.Apply(UseDebugParams));
break;
WebBasedGeneratorConfig.Apply();
break;
case ConverterMode.Mindmapper:
MindMapCreatorConfig.Run(null);
break;
case ConverterMode.Dnn2sxc:
Dnn2sxcConfig.Apply();
break;
case ConverterMode.DatasetUpdater:

foreach (var config in this.DatasetUpdaterConfigs)
{
if (config.Enabled)
{
Logger.LogTitle($"Updating Dataset {config.SourceDataset.Name}");
await config.Apply(UseDebugParams).ConfigureAwait(false);
Logger.LogTitle($"Updated Dataset {config.SourceDataset.Name}");
}

}
break;
default:
throw new ArgumentOutOfRangeException();
}
return true;
}
throw new ArgumentOutOfRangeException();
}
return true;
}


}
}
}
Loading

0 comments on commit 4510306

Please sign in to comment.