diff --git a/src/Purrse.Api/Services/ChatService.cs b/src/Purrse.Api/Services/ChatService.cs index ed8bcdf..57e87ae 100644 --- a/src/Purrse.Api/Services/ChatService.cs +++ b/src/Purrse.Api/Services/ChatService.cs @@ -198,7 +198,8 @@ public class ChatService : IChatService Model = modelName, Messages = ollamaMessages, Stream = false, - Tools = tools + Tools = tools, + Options = new OllamaRequestOptions { NumCtx = 16384 } }; var response = await CallOllamaAsync(ollamaUrl, ollamaRequest); @@ -270,7 +271,8 @@ public class ChatService : IChatService Model = modelName, Messages = ollamaMessages, Stream = false, - Tools = null // drop tools so the model focuses on the page data + Tools = null, // drop tools so the model focuses on the page data + Options = new OllamaRequestOptions { NumCtx = 16384 } }; var retryResponse = await CallOllamaAsync(ollamaUrl, retryRequest); rawContent = retryResponse?.Message?.Content; diff --git a/src/Purrse.Core/DTOs/ChatDtos.cs b/src/Purrse.Core/DTOs/ChatDtos.cs index 962adb7..6d67542 100644 --- a/src/Purrse.Core/DTOs/ChatDtos.cs +++ b/src/Purrse.Core/DTOs/ChatDtos.cs @@ -45,6 +45,16 @@ public class OllamaToolChatRequest [JsonPropertyName("tools")] public List? Tools { get; set; } + + [JsonPropertyName("options")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public OllamaRequestOptions? Options { get; set; } +} + +public class OllamaRequestOptions +{ + [JsonPropertyName("num_ctx")] + public int NumCtx { get; set; } } public class OllamaToolMessage