Appsettings für API Keys
This commit is contained in:
parent
8295be40f0
commit
57c110aea3
|
@ -6,6 +6,7 @@
|
|||
@using OpenAI_API.Models
|
||||
@using System.Diagnostics
|
||||
|
||||
@inject IConfiguration Config
|
||||
@inject TooltipService TooltipService
|
||||
@inject DialogService DialogService
|
||||
|
||||
|
@ -169,14 +170,14 @@
|
|||
,
|
||||
new() { Position = TooltipPosition.Bottom, Duration = null});
|
||||
|
||||
private string _imagePromptEnglish = "\"Painting of a soccer match with the Hamburger SV team scoring multiple goals, vibrant colors and dynamic brushstrokes.\"";
|
||||
private string _imageDescription = "Ich habe mich für diese Interpretation des Titels entschieden, um die Dynamik und den Erfolg des Hamburger SV Fußballvereins darzustellen. Durch die Darstellung eines Spiels, in dem der HSV viele Tore schießt, wird die Leidenschaft und das Streben nach Erfolg hervorgehoben. Die lebendigen Farben und die dynamischen Pinselstriche sollen die Energie und Aufregung des Spiels wiedergeben.";
|
||||
private string _imagePromptEnglish = "";
|
||||
private string _imageDescription = "";
|
||||
private string _imagePrompt = "";
|
||||
|
||||
private float temperature = 0.9f;
|
||||
private string request = "";
|
||||
private string addons = "";
|
||||
private OpenAIAPI api = new OpenAIAPI("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");
|
||||
private OpenAIAPI _openAiApi;
|
||||
private Conversation converse;
|
||||
|
||||
private string _basePrompt;
|
||||
|
@ -224,17 +225,22 @@
|
|||
|
||||
private readonly HttpClient _client = new();
|
||||
|
||||
private string _inferenceApiKey = "";
|
||||
private string _openAiApiKey = "";
|
||||
|
||||
protected override Task OnInitializedAsync()
|
||||
{
|
||||
_inferenceApiKey = Config.GetValue<string>("API:HF_Inference");
|
||||
_openAiApiKey = Config.GetValue<string>("API:OpenAI");
|
||||
|
||||
_openAiApi = new OpenAIAPI(_openAiApiKey);
|
||||
|
||||
var inferenceModelUrl = "https://api-inference.huggingface.co/models/Nacken/ki-kunst-kirsten-kloeckner-colab";
|
||||
|
||||
// TODO: nicht im repo speichern
|
||||
var API_TOKEN = "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";
|
||||
|
||||
|
||||
//_client.BaseAddress = new Uri(inferenceModelUrl);
|
||||
|
||||
_client.DefaultRequestHeaders.Clear();
|
||||
_client.DefaultRequestHeaders.Add("Authorization", $"Bearer {API_TOKEN}");
|
||||
_client.DefaultRequestHeaders.Add("Authorization", $"Bearer {_inferenceApiKey}");
|
||||
|
||||
return base.OnInitializedAsync();
|
||||
}
|
||||
|
@ -313,7 +319,7 @@
|
|||
// Cache deaktivieren, damit Huggingface für den selben Prompt unterschiedliche Ergebnisse liefert
|
||||
use_cache = false,
|
||||
// Erst wenn wir bereits in einem retry sind warten wir implizit auf das Model. (ignoriert quasi 503-Fehler)
|
||||
wait_for_model = isRetry
|
||||
wait_for_model = true
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -398,7 +404,7 @@
|
|||
Model = Model.ChatGPTTurbo,
|
||||
};
|
||||
|
||||
converse = api.Chat.CreateConversation(chatRequest);
|
||||
converse = _openAiApi.Chat.CreateConversation(chatRequest);
|
||||
converse.AppendUserInput(_basePrompt + " " + request);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -5,5 +5,9 @@
|
|||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
"API": {
|
||||
"OpenAI": "<put OpenAI Key here>",
|
||||
"HF_Inference": "<put Hugging Face inference API Key here>"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue