feat(backend): add LLM provider abstraction, contextual ranking and explanations
Add a pluggable LLM provider with an offline template fallback, prompt builder, contextual match scoring (area/location boosts, availability), per-solution explanations and in-memory request limiting for cost control.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
namespace TarninaHub.Application.Matchmaking;
|
||||
|
||||
public sealed record LlmPrompt(string System, string User);
|
||||
|
||||
public static class MatchPromptBuilder
|
||||
{
|
||||
private const string SystemPrompt =
|
||||
"Jesteś asystentem Małopolskiego Hubu Innowacji Społecznych. " +
|
||||
"Wyjaśnij po polsku, prostym językiem (maks. 2 zdania), dlaczego proponowana " +
|
||||
"innowacja pasuje do zgłoszonej potrzeby. Nie wymyślaj faktów.";
|
||||
|
||||
public static LlmPrompt BuildExplanation(
|
||||
string problemTitle,
|
||||
string problemDescription,
|
||||
string challengeId,
|
||||
string innovationTitle,
|
||||
string innovationSummary,
|
||||
string stage,
|
||||
double score)
|
||||
{
|
||||
var user =
|
||||
$"Potrzeba: {problemTitle}\n" +
|
||||
$"Opis: {problemDescription}\n" +
|
||||
$"Obszar: {challengeId}\n" +
|
||||
$"Proponowana innowacja: {innovationTitle}\n" +
|
||||
$"Streszczenie: {innovationSummary}\n" +
|
||||
$"Etap: {stage}\n" +
|
||||
$"Ocena dopasowania: {score:0.00}\n" +
|
||||
"Uzasadnij krótko dopasowanie.";
|
||||
|
||||
return new LlmPrompt(SystemPrompt, user);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user