Start of Datenbank
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user