mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 11:59:48 +00:00
WIP: Implementing a coding assistant
This commit is contained in:
parent
a9ca51377e
commit
4391128ed7
@ -8,4 +8,5 @@
|
||||
<AssistantBlock Name="Icon Finder" Description="Using a LLM to find an icon for a given context." Icon="@Icons.Material.Filled.FindInPage" Link="/assistant/icons"/>
|
||||
<AssistantBlock Name="Text Summarizer" Description="Using a LLM to summarize a given text." Icon="@Icons.Material.Filled.TextSnippet" Link="/assistant/summarizer"/>
|
||||
<AssistantBlock Name="Translator" Description="Translate text into another language." Icon="@Icons.Material.Filled.Translate" Link="/assistant/translator"/>
|
||||
<AssistantBlock Name="Coding" Description="Get coding and debugging support from a LLM." Icon="@Icons.Material.Filled.Code" Link="/assistant/coding"/>
|
||||
</MudGrid>
|
@ -0,0 +1,4 @@
|
||||
@page "/assistant/coding"
|
||||
@using AIStudio.Settings
|
||||
@using AIStudio.Tools
|
||||
@inherits AssistantBaseCore
|
@ -0,0 +1,24 @@
|
||||
namespace AIStudio.Components.Pages.Coding;
|
||||
|
||||
public partial class AssistantCoding : AssistantBaseCore
|
||||
{
|
||||
protected override string Title => "Coding Assistant";
|
||||
|
||||
protected override string Description =>
|
||||
"""
|
||||
This coding assistant supports you in writing code. Provide some coding context by copying and pasting
|
||||
your code into the input fields. You might assign an ID to your code snippet to easily reference it later.
|
||||
When you have compiler messages, you can paste them into the input fields to get help with debugging as well.
|
||||
""";
|
||||
|
||||
protected override string SystemPrompt =>
|
||||
"""
|
||||
You are a friendly, helpful senior software developer with extensive experience in various programming languages
|
||||
and concepts. You are familiar with principles like DRY, KISS, YAGNI, and SOLID and can apply and explain them.
|
||||
You know object-oriented programming, as well as functional programming and procedural programming. You are also
|
||||
familiar with design patterns and can explain them. You are an expert of debugging and can help with compiler
|
||||
messages. You can also help with code refactoring and optimization.
|
||||
""";
|
||||
|
||||
private readonly List<CodingContext> codingContexts = new();
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
namespace AIStudio.Components.Pages.Coding;
|
||||
|
||||
public readonly record struct CodingContext(string Id, CommonCodingLanguages Language, string Code);
|
@ -0,0 +1 @@
|
||||
<MudTextField T="string" @bind-Text="@this.inputText" Validation="@this.ValidatingText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Your input" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
@ -0,0 +1,28 @@
|
||||
using AIStudio.Settings;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Components.Pages.Coding;
|
||||
|
||||
public partial class CodingContextItem : ComponentBase
|
||||
{
|
||||
[Parameter]
|
||||
public CodingContext CodingContext { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected SettingsManager SettingsManager { get; set; } = null!;
|
||||
|
||||
private static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
// Configure the spellchecking for the user input:
|
||||
this.SettingsManager.InjectSpellchecking(USER_INPUT_ATTRIBUTES);
|
||||
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
namespace AIStudio.Components.Pages.Coding;
|
||||
|
||||
public static class CommonCodingLanguageExtensions
|
||||
{
|
||||
public static string Name(this CommonCodingLanguages language) => language switch
|
||||
{
|
||||
CommonCodingLanguages.NONE => "None",
|
||||
|
||||
CommonCodingLanguages.BASH => "Bash",
|
||||
CommonCodingLanguages.C => "C",
|
||||
CommonCodingLanguages.CPP => "C++",
|
||||
CommonCodingLanguages.CSHARP => "C#",
|
||||
CommonCodingLanguages.CSS => "CSS",
|
||||
CommonCodingLanguages.FORTRAN => "Fortran",
|
||||
CommonCodingLanguages.GDSCRIPT => "GDScript",
|
||||
CommonCodingLanguages.GO => "Go",
|
||||
CommonCodingLanguages.HTML => "HTML",
|
||||
CommonCodingLanguages.JAVA => "Java",
|
||||
CommonCodingLanguages.JAVASCRIPT => "JavaScript",
|
||||
CommonCodingLanguages.JSON => "JSON",
|
||||
CommonCodingLanguages.JULIA => "Julia",
|
||||
CommonCodingLanguages.KOTLIN => "Kotlin",
|
||||
CommonCodingLanguages.LUA => "Lua",
|
||||
CommonCodingLanguages.MARKDOWN => "Markdown",
|
||||
CommonCodingLanguages.MATHEMATICA => "Mathematica",
|
||||
CommonCodingLanguages.MATLAB => "MATLAB",
|
||||
CommonCodingLanguages.PHP => "PHP",
|
||||
CommonCodingLanguages.POWERSHELL => "PowerShell",
|
||||
CommonCodingLanguages.PROLOG => "Prolog",
|
||||
CommonCodingLanguages.PYTHON => "Python",
|
||||
CommonCodingLanguages.R => "R",
|
||||
CommonCodingLanguages.RUBY => "Ruby",
|
||||
CommonCodingLanguages.RUST => "Rust",
|
||||
CommonCodingLanguages.SQL => "SQL",
|
||||
CommonCodingLanguages.SWIFT => "Swift",
|
||||
CommonCodingLanguages.TYPESCRIPT => "TypeScript",
|
||||
CommonCodingLanguages.XML => "XML",
|
||||
|
||||
CommonCodingLanguages.OTHER => "Other",
|
||||
_ => "Unknown"
|
||||
};
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
namespace AIStudio.Components.Pages.Coding;
|
||||
|
||||
public enum CommonCodingLanguages
|
||||
{
|
||||
NONE,
|
||||
|
||||
BASH,
|
||||
C,
|
||||
CPP,
|
||||
CSHARP,
|
||||
CSS,
|
||||
FORTRAN,
|
||||
GDSCRIPT,
|
||||
GO,
|
||||
HTML,
|
||||
JAVA,
|
||||
JAVASCRIPT,
|
||||
JSON,
|
||||
JULIA,
|
||||
KOTLIN,
|
||||
LUA,
|
||||
MARKDOWN,
|
||||
MATHEMATICA,
|
||||
MATLAB,
|
||||
PHP,
|
||||
POWERSHELL,
|
||||
PROLOG,
|
||||
PYTHON,
|
||||
R,
|
||||
RUBY,
|
||||
RUST,
|
||||
SQL,
|
||||
SWIFT,
|
||||
TYPESCRIPT,
|
||||
XML,
|
||||
|
||||
OTHER,
|
||||
}
|
Loading…
Reference in New Issue
Block a user