/
afanasevn
/
PdfEncoder
Обзор
Документация
Войти
/
afanasevn
/
PdfEncoder
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/PdfEncoder.Application/Abstractions/ILlmClient.cs
63 строки
2 KB
IBS\NAfanasev
Remote LLM base functional
01 июл 2026, 15:54
01 июл 2026, 15:54
05aa80e
Код
Авторство
О чём код?
namespace PdfEncoder.Application.Abstractions; /// <summary> /// Thin wrapper над OpenAI-compatible chat completions для structured JSON. /// </summary> public interface ILlmClient { /// <summary> /// Выполняет chat completion и десериализует JSON-ответ в <typeparamref name="T"/>. /// </summary> /// <typeparam name="T">Целевой тип structured response.</typeparam> /// <param name="request">Параметры вызова.</param> /// <param name="ct">Токен отмены.</param> Task<LlmCompletionResult<T>> CompleteStructuredAsync<T>( LlmStructuredRequest request, CancellationToken ct); } /// <summary> /// Параметры structured LLM-вызова. /// </summary> public sealed record LlmStructuredRequest { /// <summary> /// Slug модели. /// </summary> public string Model { get; init; } = string.Empty; /// <summary> /// System prompt. /// </summary> public string SystemPrompt { get; init; } = string.Empty; /// <summary> /// User prompt. /// </summary> public string UserPrompt { get; init; } = string.Empty; /// <summary> /// Имя шага для LlmUsageLogs. /// </summary> public string StepName { get; init; } = string.Empty; /// <summary> /// Идентификатор job документа. /// </summary> public Guid DocumentJobId { get; init; } /// <summary> /// Использовать native <c>response_format: json_object</c>, если gateway поддерживает. /// </summary> public bool PreferNativeJsonObject { get; init; } = true; } /// <summary> /// Результат structured LLM-вызова. /// </summary> /// <typeparam name="T">Тип десериализованных данных.</typeparam> public sealed record LlmCompletionResult<T>( T Data, int PromptTokens, int CompletionTokens, int LatencyMs);