Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ai): add more AI methods support #263

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
243 changes: 243 additions & 0 deletions src/Crowdin.Api/AI/AiApiExecutor.cs

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions src/Crowdin.Api/AI/AiDatasetPurpose.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

using System.ComponentModel;
using JetBrains.Annotations;

namespace Crowdin.Api.AI
{
[PublicAPI]
public enum AiDatasetPurpose
{
[Description("training")]
Training,

[Description("validation")]
Validation
}
}
60 changes: 60 additions & 0 deletions src/Crowdin.Api/AI/AiFineTuningDataset.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

using System;
using JetBrains.Annotations;
using Newtonsoft.Json;

namespace Crowdin.Api.AI
{
[PublicAPI]
public class AiFineTuningDataset
{
[JsonProperty("identifier")]
public string Identifier { get; set; }

[JsonProperty("status")]
public OperationStatus Status { get; set; }

[JsonProperty("progress")]
public int Progress { get; set; }

[JsonProperty("attributes")]
public AttributesObject Attributes { get; set; }

[JsonProperty("createdAt")]
public DateTimeOffset CreatedAt { get; set; }

[JsonProperty("updatedAt")]
public DateTimeOffset UpdatedAt { get; set; }

[JsonProperty("startedAt")]
public DateTimeOffset StartedAt { get; set; }

[JsonProperty("finishedAt")]
public DateTimeOffset FinishedAt { get; set; }

[PublicAPI]
public class AttributesObject
{
[JsonProperty("projectIds")]
public int[] ProjectIds { get; set; }

[JsonProperty("purpose")]
public AiDatasetPurpose Purpose { get; set; }

[JsonProperty("dateFrom")]
public DateTimeOffset? DateFrom { get; set; }

[JsonProperty("dateTo")]
public DateTimeOffset? DateTo { get; set; }

[JsonProperty("maxFileSize")]
public int? MaxFileSize { get; set; }

[JsonProperty("minExamplesCount")]
public int? MinExamplesCount { get; set; }

[JsonProperty("maxExamplesCount")]
public int? MaxExamplesCount { get; set; }
}
}
}
72 changes: 72 additions & 0 deletions src/Crowdin.Api/AI/AiFineTuningJob.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

using System;
using JetBrains.Annotations;
using Newtonsoft.Json;

#nullable enable

namespace Crowdin.Api.AI
{
[PublicAPI]
public class AiFineTuningJob
{
[JsonProperty("identifier")]
public string Identifier { get; set; } = null!;

[JsonProperty("status")]
public OperationStatus Status { get; set; }

[JsonProperty("progress")]
public int Progress { get; set; }

[JsonProperty("attributes")]
public AttributesObject Attributes { get; set; } = null!;

[JsonProperty("createdAt")]
public DateTimeOffset CreatedAt { get; set; }

[JsonProperty("updatedAt")]
public DateTimeOffset UpdatedAt { get; set; }

[JsonProperty("startedAt")]
public DateTimeOffset StartedAt { get; set; }

[JsonProperty("finishedAt")]
public DateTimeOffset FinishedAt { get; set; }

[PublicAPI]
public class AttributesObject
{
[JsonProperty("dryRun")]
public bool DryRun { get; set; }

[JsonProperty("hyperParameters")]
public AiHyperParameters? HyperParameters { get; set; }

[JsonProperty("trainingOptions")]
public AiTrainingOptions TrainingOptions { get; set; } = null!;

[JsonProperty("validationOptions")]
public AiValidationOptions? ValidationOptions { get; set; }

[JsonProperty("fineTunedModel")]
public string? FineTunedModel { get; set; }

[JsonProperty("trainedTokensCount")]
public int? TrainingTokensCount { get; set; }

[JsonProperty("metadata")]
public MetadataObject? Metadata { get; set; }

[PublicAPI]
public class MetadataObject
{
[JsonProperty("cost")]
public float? Cost { get; set; }

[JsonProperty("costCurrency")]
public string? CostCurrency { get; set; }
}
}
}
}
21 changes: 21 additions & 0 deletions src/Crowdin.Api/AI/AiHyperParameters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

using JetBrains.Annotations;
using Newtonsoft.Json;

#nullable enable

namespace Crowdin.Api.AI
{
[PublicAPI]
public class AiHyperParameters
{
[JsonProperty("batchSize")]
public int? BatchSize { get; set; }

[JsonProperty("learningRateMultiplier")]
public float? LearningRateMultiplier { get; set; }

[JsonProperty("nEpochs")]
public int? NEpochs { get; set; }
}
}
42 changes: 42 additions & 0 deletions src/Crowdin.Api/AI/AiPromptCompletion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

using System;
using JetBrains.Annotations;
using Newtonsoft.Json;

namespace Crowdin.Api.AI
{
[PublicAPI]
public class AiPromptCompletion
{
[JsonProperty("identifier")]
public string Identifier { get; set; }

[JsonProperty("status")]
public OperationStatus Status { get; set; }

[JsonProperty("progress")]
public int Progress { get; set; }

[JsonProperty("attributes")]
public AttributesObject Attributes { get; set; }

[JsonProperty("createdAt")]
public DateTimeOffset CreatedAt { get; set; }

[JsonProperty("updatedAt")]
public DateTimeOffset UpdatedAt { get; set; }

[JsonProperty("startedAt")]
public DateTimeOffset StartedAt { get; set; }

[JsonProperty("finishedAt")]
public DateTimeOffset FinishedAt { get; set; }

[PublicAPI]
public class AttributesObject
{
[JsonProperty("aiPromptId")]
public int AiPromptId { get; set; }
}
}
}
95 changes: 75 additions & 20 deletions src/Crowdin.Api/AI/AiPromptConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@

using System.Collections.Generic;
using JetBrains.Annotations;
using Newtonsoft.Json;

#nullable enable

namespace Crowdin.Api.AI
{
[PublicAPI]
Expand All @@ -18,41 +21,71 @@ public class BasicModeAiPromptConfiguration : AiPromptConfiguration
public override AiPromptMode Mode => AiPromptMode.Basic;

[JsonProperty("companyDescription")]
public string CompanyDescription { get; set; }
public string? CompanyDescription { get; set; }

[JsonProperty("projectDescription")]
public string ProjectDescription { get; set; }
public string? ProjectDescription { get; set; }

[JsonProperty("audienceDescription")]
public string AudienceDescription { get; set; }
public string? AudienceDescription { get; set; }

[JsonProperty("otherLanguageTranslations")]
public OtherLanguageTranslationsConfig OtherLanguageTranslations { get; set; }
public OtherLanguageTranslationsConfig? OtherLanguageTranslations { get; set; }

[JsonProperty("glossaryTerms")]
public bool GlossaryTerms { get; set; }
public bool? GlossaryTerms { get; set; }

[JsonProperty("tmSuggestions")]
public bool TmSuggestions { get; set; }
public bool? TmSuggestions { get; set; }

[JsonProperty("fileContent")]
public bool FileContent { get; set; }
public bool? FileContent { get; set; }

[JsonProperty("fileContext")]
public bool FileContext { get; set; }
public bool? FileContext { get; set; }

[JsonProperty("publicProjectDescription")]
public bool PublicProjectDescription { get; set; }

[PublicAPI]
public class OtherLanguageTranslationsConfig
{
[JsonProperty("isEnabled")]
public bool IsEnabled { get; set; }

[JsonProperty("languageIds")]
public string[] LanguageIds { get; set; }
}
public bool? PublicProjectDescription { get; set; }
}

[PublicAPI]
public class BasicModeAssistActionAiPromptConfiguration : AiPromptConfiguration
{
[JsonProperty("mode")]
public override AiPromptMode Mode => AiPromptMode.Basic;

[JsonProperty("companyDescription")]
public string? CompanyDescription { get; set; }

[JsonProperty("projectDescription")]
public string? ProjectDescription { get; set; }

[JsonProperty("audienceDescription")]
public string? AudienceDescription { get; set; }

[JsonProperty("otherLanguageTranslations")]
public OtherLanguageTranslationsConfig? OtherLanguageTranslations { get; set; }

[JsonProperty("glossaryTerms")]
public bool? GlossaryTerms { get; set; }

[JsonProperty("tmSuggestions")]
public bool? TmSuggestions { get; set; }

[JsonProperty("fileContext")]
public bool? FileContext { get; set; }

[JsonProperty("screenshots")]
public bool? Screenshots { get; set; }

[JsonProperty("publicProjectDescription")]
public bool? PublicProjectDescription { get; set; }

[JsonProperty("siblingsStrings")]
public bool? SiblingsStrings { get; set; }

[JsonProperty("filteredStrings")]
public bool? FilteredStrings { get; set; }
}

[PublicAPI]
Expand All @@ -61,7 +94,29 @@ public class AdvancedModeAiPromptConfiguration : AiPromptConfiguration
[JsonProperty("mode")]
public override AiPromptMode Mode => AiPromptMode.Advanced;

[JsonProperty("screenshots")]
public bool? Screenshots { get; set; }

[JsonProperty("prompt")]
public string Prompt { get; set; }
public string Prompt { get; set; } = null!;

[JsonProperty("otherLanguageTranslations")]
public OtherLanguageTranslationsConfig? OtherLanguageTranslations { get; set; }
}

[PublicAPI]
public class ExternalModeAiPromptConfiguration : AiPromptConfiguration
{
[JsonProperty("mode")]
public override AiPromptMode Mode => AiPromptMode.External;

[JsonProperty("identifier")]
public string Identifier { get; set; } = null!;

[JsonProperty("key")]
public string Key { get; set; } = null!;

[JsonProperty("options")]
public IDictionary<string, object>? Options { get; set; }
}
}
Loading
Loading