ApiClient

This commit is contained in:
2026-01-27 17:12:59 +01:00
parent b45b51bff4
commit 2269d18073
5 changed files with 71 additions and 4 deletions

View File

@@ -104,6 +104,7 @@
<Compile Include="Context\Summary\Navigation\ServiceRecordNavigationCS.cs" />
<Compile Include="Context\Summary\Detail\SupportConceptDetailCS.cs" />
<Compile Include="Context\Summary\Navigation\SupportConceptNavigationCS.cs" />
<Compile Include="Facade\AiPromptsApiClient.cs" />
<Compile Include="Facade\DefaultErrorExtractor.cs" />
<Compile Include="Facade\LLM\BaseLLMApiClient.cs" />
<Compile Include="Facade\LLM\OllamaApiClient.cs" />

View File

@@ -0,0 +1,60 @@
using BeWo.ServerUtils.ApiFacade;
using BS.Shared.DataContracts.Feature.AI;
using BS.Shared.DataContracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BS.Shared;
using BS.Shared.Interface;
namespace AICore.Facade
{
public class AiPromptsApiClient
{
private protected readonly HttpClientFacade _GetClientFacade;
private protected readonly IApiErrorExtractor _ErrorExtractor;
public AiPromptsApiClient()
{
var base_url = "https://test2.evplaner.de";
_GetClientFacade = new HttpClientFacade(base_url, null, false);
_ErrorExtractor = new DefaultErrorExtractor();
}
public ApiResponse<IEnumerable<AiPromptbausteinPromptDC>> GetAiPrompts()
{
var prompts = new List<AiPromptbausteinPromptDC>();
var response_format = new[]
{
new
{
promptid = "",
title = "",
prompt = "",
description = ""
}
};
var response = _GetClientFacade.GetAnonymousTypeAsync("api/prompts/4368658435", response_format, _ErrorExtractor).GetAwaiter().GetResult();
if (!response.Success)
{
throw new NotImplementedException();
}
var data = response.Data.Select(x => new AiPromptbausteinPromptDC()
{
PromptId = x.promptid,
Title = x.title,
Description = x.description,
Prompt = x.prompt,
});
return ApiResponse<IEnumerable<AiPromptbausteinPromptDC>>.SuccessResponse(data);
}
}
}

View File

@@ -26,11 +26,12 @@ namespace BeWo.ServerUtils.ApiFacade
if (string.IsNullOrEmpty(base_url))
throw new ArgumentNullException("HttpClient: base_url is missing");
if (string.IsNullOrWhiteSpace(api_key))
throw new ArgumentNullException("HttpClient: token is missing");
//if (string.IsNullOrWhiteSpace(api_key))
// throw new ArgumentNullException("HttpClient: token is missing");
Base_Url = base_url;
SetToken(api_key);
if (!string.IsNullOrWhiteSpace(api_key))
SetToken(api_key);
DirectConnect = directConntect;
}