summaryrefslogtreecommitdiff
path: root/src/Agent.Core/Ollama/OllamaModels.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Agent.Core/Ollama/OllamaModels.cs')
-rw-r--r--src/Agent.Core/Ollama/OllamaModels.cs46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/Agent.Core/Ollama/OllamaModels.cs b/src/Agent.Core/Ollama/OllamaModels.cs
new file mode 100644
index 0000000..823a178
--- /dev/null
+++ b/src/Agent.Core/Ollama/OllamaModels.cs
@@ -0,0 +1,46 @@
+using System.Text.Json.Serialization;
+using System.Text.Json;
+using Agent.Core.Tools;
+
+namespace Agent.Core.Ollama;
+
+public sealed record OllamaMessage(
+ [property: JsonPropertyName("role")] string Role,
+ [property: JsonPropertyName("content")] string Content,
+ [property: JsonPropertyName("images"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] IReadOnlyList<string>? Images = null,
+ [property: JsonPropertyName("tool_name"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] string? ToolName = null,
+ [property: JsonPropertyName("tool_calls"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] IReadOnlyList<OllamaToolCall>? ToolCalls = null);
+
+public sealed record OllamaToolCall([property: JsonPropertyName("function")] OllamaFunctionCall Function);
+public sealed record OllamaFunctionCall(
+ [property: JsonPropertyName("name")] string Name,
+ [property: JsonPropertyName("arguments")] JsonElement Arguments);
+
+public sealed record OllamaToolDefinition(
+ [property: JsonPropertyName("type")] string Type,
+ [property: JsonPropertyName("function")] OllamaFunctionDefinition Function);
+public sealed record OllamaFunctionDefinition(
+ [property: JsonPropertyName("name")] string Name,
+ [property: JsonPropertyName("description")] string Description,
+ [property: JsonPropertyName("parameters")] JsonElement Parameters);
+
+public sealed class OllamaChatRequest
+{
+ [JsonPropertyName("model")] public required string Model { get; init; }
+ [JsonPropertyName("messages")] public required IReadOnlyList<OllamaMessage> Messages { get; init; }
+ [JsonPropertyName("stream")] public bool Stream { get; init; }
+ [JsonPropertyName("think")] public bool Think { get; init; }
+ [JsonPropertyName("keep_alive")] public required string KeepAlive { get; init; }
+ [JsonPropertyName("options")] public required IReadOnlyDictionary<string, System.Text.Json.JsonElement> Options { get; init; }
+ [JsonPropertyName("tools"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public IReadOnlyList<OllamaToolDefinition>? Tools { get; init; }
+}
+
+public sealed class OllamaChatResponse
+{
+ [JsonPropertyName("message")] public OllamaMessage? Message { get; init; }
+ [JsonPropertyName("prompt_eval_count")] public long PromptEvalCount { get; init; }
+ [JsonPropertyName("eval_count")] public long EvalCount { get; init; }
+ [JsonPropertyName("error")] public string? Error { get; init; }
+}
+
+public sealed record OllamaResult(string Content, long InputTokens, long OutputTokens, IReadOnlyList<OllamaToolCall>? ToolCalls = null);