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

Implemented the mentor's backend. #1492

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d26eade
Added the database tables for the AI Mentor.
deyordanov Nov 13, 2024
54ff85e
Implemented the IEntity interface.
deyordanov Nov 14, 2024
fab4952
Added validation for the mentor's settings.
deyordanov Nov 18, 2024
3c5a777
Implemented the Administration's backend logic.
deyordanov Nov 18, 2024
94923d1
Implemented the mentor's backend.
deyordanov Nov 19, 2024
9bccb66
Merge branch '1604-implement-ai-mentor' into 1605-create-api-integrat…
deyordanov Nov 20, 2024
e0dbeb0
Resolved all review comments.
deyordanov Nov 21, 2024
400780e
Resolved some comments.
deyordanov Nov 21, 2024
f0387ac
Added the retrieval of all problem resources for a given contest.
deyordanov Nov 21, 2024
0b31f6a
Updated the word document parsing algorithm and made the chat's restr…
deyordanov Nov 22, 2024
10ed9b4
Minor fixes.
deyordanov Nov 25, 2024
558a843
Merge branch '1604-implement-ai-mentor' into 1605-create-api-integrat…
deyordanov Nov 25, 2024
2df78b8
Seeded the mentor's settings.
deyordanov Nov 25, 2024
ec8a180
Added a generic seeder data service.
deyordanov Nov 25, 2024
58459e9
Seeded the mentor's prompt templates.
deyordanov Nov 25, 2024
fdcd6ad
The conversation's messages are not individual for each problem.
deyordanov Nov 25, 2024
a6e6c3f
Added caching for the mentor's system message.
deyordanov Nov 25, 2024
a2c339c
Changed the approach for keeping separate messages for each problem.
deyordanov Nov 25, 2024
f70fa15
Implemented the BE for the mentor's prompt templates administration.
deyordanov Nov 25, 2024
791eea9
Added permission services.
deyordanov Nov 25, 2024
49e207a
Improved the query for retrieving the problem resources.
deyordanov Nov 27, 2024
9f6242a
Merge branch '1604-implement-ai-mentor' into 1605-create-api-integrat…
deyordanov Nov 27, 2024
5c1a28f
Added a method for downloading resources from svn.
deyordanov Nov 27, 2024
4d53b6b
The HttpClient is not longer created on each request.
deyordanov Dec 2, 2024
c7138a5
Recovered 20241113161002_AddMentorTables.Designer.cs
deyordanov Dec 2, 2024
879983c
Added a minor fix regarding the svn resource's path.
deyordanov Dec 2, 2024
cf0ee92
Added a constant for svn.
deyordanov Dec 2, 2024
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
11 changes: 11 additions & 0 deletions Common/OJS.Common/Enumerations/MentorMessageRole.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace OJS.Common.Enumerations;

public enum MentorMessageRole
{
System,
User,
Assistant,
Tool,
Function,
Information,
}
14 changes: 14 additions & 0 deletions Common/OJS.Common/Enumerations/OpenAiModels.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace OJS.Common.Enumerations;

public enum OpenAIModels
{
Gpt4o,
Gpt4oMini,
O1Preview,
O1Mini,
Gpt35Turbo,
TextEmbedding3Small,
TextEmbedding3Large,
DallE3,
Whisper
}
21 changes: 21 additions & 0 deletions Common/OJS.Common/Extensions/OpenAiModelExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace OJS.Common.Extensions;

using System;
using OJS.Common.Enumerations;

public static class OpenAiModelExtensions
{
public static string ToModelString(this OpenAIModels model) => model switch
{
OpenAIModels.Gpt4o => "gpt-4o",
OpenAIModels.Gpt4oMini => "gpt-4o-mini",
OpenAIModels.O1Preview => "o1-preview",
OpenAIModels.O1Mini => "o1-mini",
OpenAIModels.Gpt35Turbo => "gpt-3.5-turbo",
OpenAIModels.TextEmbedding3Small => "text-embedding-3-small",
OpenAIModels.TextEmbedding3Large => "text-embedding-3-large",
OpenAIModels.DallE3 => "dall-e-3",
OpenAIModels.Whisper => "whisper",
_ => throw new ArgumentOutOfRangeException(nameof(model), "The provided mentor model is invalid."),
};
}
7 changes: 7 additions & 0 deletions Common/OJS.Common/GlobalConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ public static class Submissions

public static class Settings
{
public const string Mentor = "Mentor";
public const string MentorModel = "MentorModel";
public const int MentorMessagesSentCount = 10;
public const int MentorMaxInputTokenCount = 4096;
public const int MentorMaxOutputTokenCount = 2048;
public const int MentorQuotaLimit = 15;
public const int MentorQuotaResetTimeInMinutes = 120;
public const string MaxSubmissionTimeToExecuteAllowedForBatchRetest = "MaxSubmissionTimeToExecuteAllowedForBatchRetest";
public const string MaxSubmissionsCountAllowedForBatchRetest = "MaxSubmissionsCountAllowedForBatchRetest";
public const string MaxWorkersWorkingTimeInSeconds = "MaxWorkersWorkingTimeInSeconds";
Expand Down
2 changes: 2 additions & 0 deletions Data/OJS.Data.Models/Contests/ContestCategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class ContestCategory : DeletableAuditInfoEntity<int>, IOrderableEntity,

public bool IsVisible { get; set; }

public bool AllowMentor { get; set; }

[InverseProperty(nameof(Parent))]
public virtual ICollection<ContestCategory> Children { get; set; } = new HashSet<ContestCategory>();

Expand Down
6 changes: 3 additions & 3 deletions Data/OJS.Data.Models/Mentor/UserMentor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
using OJS.Data.Models.Common;
using OJS.Data.Models.Users;

public class UserMentor : IEntity
public class UserMentor : IEntity<string>
{
[Key]
[ForeignKey(nameof(User))]
public string UserId { get; set; } = default!;
public string Id { get; set; } = default!;

public virtual UserProfile User { get; set; } = null!;

public DateTimeOffset QuotaResetTime { get; set; }

public int RequestsMade { get; set; }

public int QuotaLimit { get; set; }
public int? QuotaLimit { get; set; }

public DateTime CreatedOn { get; set; }

Expand Down
Loading
Loading