Start of Datenbank
This commit is contained in:
12
KIKunstKirstenKlöckner/.config/dotnet-tools.json
Normal file
12
KIKunstKirstenKlöckner/.config/dotnet-tools.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "7.0.9",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -20,4 +20,8 @@
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DataAccess\DataAccess.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -4,11 +4,15 @@
|
||||
@using OpenAI_API.Chat
|
||||
@using OpenAI_API.Models
|
||||
@using System.Diagnostics
|
||||
@using DataAccess.Data
|
||||
@using DataAccess.Models
|
||||
|
||||
@inject IConfiguration Config
|
||||
@inject TooltipService TooltipService
|
||||
@inject DialogService DialogService
|
||||
|
||||
@inject BildInfoData BildInfoData;
|
||||
|
||||
<PageTitle>AiArt</PageTitle>
|
||||
|
||||
<section class="about_section layout_padding">
|
||||
@ -244,7 +248,7 @@
|
||||
private string _inferenceApiKey = "";
|
||||
private string _openAiApiKey = "";
|
||||
|
||||
protected override Task OnInitializedAsync()
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_inferenceApiKey = Config.GetValue<string>("API:HF_Inference");
|
||||
_openAiApiKey = Config.GetValue<string>("API:OpenAI");
|
||||
@ -258,7 +262,31 @@
|
||||
_client.DefaultRequestHeaders.Clear();
|
||||
_client.DefaultRequestHeaders.Add("Authorization", $"Bearer {_inferenceApiKey}");
|
||||
|
||||
return base.OnInitializedAsync();
|
||||
|
||||
BildInfoModel bildInfo = new()
|
||||
{
|
||||
BildBeschreibung = "Test",
|
||||
BildPrompt = "Tost",
|
||||
Dateiname = "Task",
|
||||
Datum = DateTime.Now,
|
||||
GPTModel = "Geht dich nichts an",
|
||||
ImageModel = "Jup",
|
||||
Wunsch = request
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
await BildInfoData.AddBildInfo(bildInfo);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -372,7 +400,9 @@
|
||||
|
||||
using Image image = await Image.LoadAsync(imageStream);
|
||||
|
||||
string imgUrl = $"generated_images/{DateTime.Now:dd_MM_yyyy_hh_mm_s_fffffff}.jpg";
|
||||
DateTime imageDate = DateTime.Now;
|
||||
|
||||
string imgUrl = $"generated_images/{imageDate:dd_MM_yyyy_hh_mm_s_fffffff}.jpg";
|
||||
|
||||
string mapPath = $"./wwwroot/{imgUrl}";
|
||||
await image.SaveAsJpegAsync(mapPath);
|
||||
@ -383,6 +413,19 @@
|
||||
string newLine = $"{imgUrl}: {request}, {desc}\n";
|
||||
await File.AppendAllTextAsync(infoTextsPath, newLine);
|
||||
|
||||
BildInfoModel bildInfo = new()
|
||||
{
|
||||
BildBeschreibung = desc,
|
||||
BildPrompt = prompt,
|
||||
Dateiname = imgUrl,
|
||||
Datum = imageDate,
|
||||
GPTModel = "Geht dich nichts an",
|
||||
ImageModel = "Jup",
|
||||
Wunsch = request
|
||||
};
|
||||
|
||||
await BildInfoData.AddBildInfo(bildInfo);
|
||||
|
||||
return imgUrl;
|
||||
}
|
||||
else
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
using DataAccess.Data;
|
||||
using DataAccess.DbAccess;
|
||||
using Radzen;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@ -8,6 +10,8 @@ builder.Services.AddServerSideBlazor();
|
||||
builder.Services.AddScoped<TooltipService>();
|
||||
builder.Services.AddScoped<DialogService>();
|
||||
builder.Services.AddScoped<NotificationService>();
|
||||
builder.Services.AddSingleton<ISqlDataAccess, SqlDataAccess>();
|
||||
builder.Services.AddSingleton<BildInfoData>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
{
|
||||
"DetailedErrors": true,
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
"DetailedErrors": true,
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Default": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=KiKunstDatenbank;Integrated Security=True;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,5 +9,8 @@
|
||||
"API": {
|
||||
"OpenAI": "<put OpenAI Key here>",
|
||||
"HF_Inference": "<put Hugging Face inference API Key here>"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Default": "<put Connection String here>"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user