Multi-agent AI laboratory with ASP.NET Core 8.0 backend and Flutter frontend. Implements CQRS architecture, OpenAPI contract-first API design. BACKEND: Agent management, conversations, executions with PostgreSQL + Ollama FRONTEND: Cross-platform UI with strict typing and Result-based error handling Co-Authored-By: Jean-Philippe Brule <jp@svrnty.io>
54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
using Codex.Dal.Entities;
|
|
|
|
namespace Codex.Dal.Services;
|
|
|
|
/// <summary>
|
|
/// Service for interacting with Ollama LLM endpoints
|
|
/// </summary>
|
|
public interface IOllamaService
|
|
{
|
|
/// <summary>
|
|
/// Generates a response from an Ollama model given conversation context
|
|
/// </summary>
|
|
/// <param name="endpoint">Ollama endpoint URL (e.g., "http://localhost:11434")</param>
|
|
/// <param name="model">Model name (e.g., "phi", "codellama:7b")</param>
|
|
/// <param name="systemPrompt">System prompt defining agent behavior</param>
|
|
/// <param name="contextMessages">Previous conversation messages for context</param>
|
|
/// <param name="userMessage">Current user message to respond to</param>
|
|
/// <param name="temperature">Temperature parameter (0.0 to 2.0)</param>
|
|
/// <param name="maxTokens">Maximum tokens to generate</param>
|
|
/// <param name="cancellationToken">Cancellation token</param>
|
|
/// <returns>Response from the model with token counts</returns>
|
|
Task<OllamaResponse> GenerateAsync(
|
|
string endpoint,
|
|
string model,
|
|
string systemPrompt,
|
|
List<ConversationMessage> contextMessages,
|
|
string userMessage,
|
|
double temperature,
|
|
int maxTokens,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Response from Ollama generation request
|
|
/// </summary>
|
|
public record OllamaResponse
|
|
{
|
|
/// <summary>
|
|
/// Generated response content
|
|
/// </summary>
|
|
public string Content { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Number of tokens in the input prompt
|
|
/// </summary>
|
|
public int? InputTokens { get; init; }
|
|
|
|
/// <summary>
|
|
/// Number of tokens in the generated output
|
|
/// </summary>
|
|
public int? OutputTokens { get; init; }
|
|
}
|