From 689ec912b016824c91001dcdd12a635534829f86 Mon Sep 17 00:00:00 2001 From: Eduardo Rezende Date: Mon, 18 Aug 2025 17:34:27 -0300 Subject: [PATCH 1/8] =?UTF-8?q?=E2=99=BB=EF=B8=8Frefactor:=20Update=20READ?= =?UTF-8?q?ME.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improving documentation and explanations --- README.md | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index d03c648..504c3b9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # AutoDoc - Git to Report πŸ“š **AutoDoc** is a simple but powerful multiplatform tool that automatically analyzes Git commits and generates structured daily CSV reports. -It leverages [LM Studio](https://lmstudio.ai/) as the AI engine to transform commit history into meaningful documentation with context-aware summaries. +It leverages AI to transform commit history into meaningful documentation with context-aware summaries. --- @@ -19,7 +19,8 @@ It leverages [LM Studio](https://lmstudio.ai/) as the AI engine to transform com - Each part is sent to the model for structured summarization. 4. **AI Integration** - - Uses LM Studio's local API (`/v1/chat/completions`). + - Can use OpenAI APIs like (`/v1/chat/completions`). + - Can use custom APIs like (`v1/messages`) - Automatically retries failed requests and waits between calls to avoid memory overload. 5. **CSV Generation** @@ -39,6 +40,8 @@ All settings are handled in the `appsettings.json` file: "Culture": "en-US", "OutputPath": "AutoDoc-Reports", "CompletionsUri": "http://localhost:1234/v1/chat/completions", + "AuthenticationHeader": "Bearer", + "ApiKey": "your_api_key_here", "DelayMilliseconds": 20000, "ModelTemperature": 0.5, "MaxRetries": 2 @@ -46,15 +49,17 @@ All settings are handled in the `appsettings.json` file: ``` πŸ”’ Explanation of Parameters: -- RepositoryPath β†’ Path to the Git repository to analyze. -- OwnerEmail β†’ Git email address for filtering commits. -- OwnerName β†’ Who is responsible for the commits. -- Culture β†’ Defines reporting culture/locale (e.g., pt-BR, en-US). -- OutputPath β†’ Directory where daily CSV files are saved. -- CompletionsUri β†’ API endpoint of LM Studio. -- DelayMilliseconds β†’ Delay between requests (prevents RAM overload). -- ModelTemperature β†’ Controls creativity of the model (0 = focused, 1 = creative). -- MaxRetries β†’ How many times to retry if a request fails. +- RepositoryPath β†’ Path to the Git repository to analyze. +- OwnerEmail β†’ Git email address for filtering commits. +- OwnerName β†’ Who is responsible for the commits. +- Culture β†’ Defines reporting culture/locale (e.g., pt-BR, en-US). +- OutputPath β†’ Directory where daily CSV files are saved. +- CompletionsUri β†’ API endpoint. +- AuthenticationHeader β†’ API Authentication method. +- ApiKey β†’ API Key if applicable. +- DelayMilliseconds β†’ Delay between requests (prevents RAM overload). +- ModelTemperature β†’ Controls creativity of the model (0 = focused, 1 = creative). +- MaxRetries β†’ How many times to retry if a request fails. --- @@ -74,8 +79,7 @@ The project is developed in/with: [Your Project languages and tools]. --- ## πŸ“¦ Requirements -LM Studio installed and running locally. -Start LM Studio server with your preferred model. +Access to an AI server. Ensure it listens on the same port as configured in appsettings.json (default: http://localhost:1234). --- @@ -90,9 +94,10 @@ Ensure it listens on the same port as configured in appsettings.json (default: h 4 - Edit Context.txt with your project context. -5 - Make sure LM Studio server is running. +5 - Make sure AI server is reachable. 6 - Execute AutoDoc.exe + - Option 1: [StartDate] [EndDate] | Explanation: The folllowing arguments will generate 1 month of reports. ```text PS C:\Users\eduar> C:\Users\eduar\Desktop\AutoDoc-win-x64\AutoDoc.exe 2025-01-01 2025-02-01 From 22e43cc53421eb6378ea011c47eb6400332db53b Mon Sep 17 00:00:00 2001 From: Eduardo Rezende Date: Mon, 18 Aug 2025 17:35:50 -0300 Subject: [PATCH 2/8] =?UTF-8?q?=E2=99=BB=EF=B8=8Frefactor:=20Update=20apps?= =?UTF-8?q?ettings.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding more fields to handle AI server requestings --- appsettings.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appsettings.json b/appsettings.json index ca0002c..426c397 100644 --- a/appsettings.json +++ b/appsettings.json @@ -5,6 +5,8 @@ "Culture": "en-US", "OutputPath": "AutoDoc-Reports", "CompletionsUri": "http://localhost:1234/v1/chat/completions", + "AuthenticationHeader": "Bearer", + "ApiKey": "your_api_key_here", "DelayMilliseconds": 20000, "ModelTemperature": 0.5, "MaxRetries": 2 From 07021b5662e5df179b84b24467888e13513ef1ea Mon Sep 17 00:00:00 2001 From: Eduardo Rezende Date: Mon, 18 Aug 2025 17:36:34 -0300 Subject: [PATCH 3/8] =?UTF-8?q?=E2=99=BB=EF=B8=8Frefactor:=20Update=20AppS?= =?UTF-8?q?ettings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding AuthenticationHeader and ApiKey fields --- src/Models/AppSettings.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Models/AppSettings.cs b/src/Models/AppSettings.cs index 129712c..890495e 100644 --- a/src/Models/AppSettings.cs +++ b/src/Models/AppSettings.cs @@ -12,6 +12,8 @@ public AppSettings() Culture = string.Empty; OutputPath = string.Empty; CompletionsUri = string.Empty; + AuthenticationHeader = string.Empty; + ApiKey = string.Empty; } public string RepositoryPath { get; set; } @@ -30,6 +32,10 @@ public AppSettings() public string CompletionsUri { get; set; } + public string AuthenticationHeader { get; set; } + + public string ApiKey { get; set; } + public int DelayMilliseconds { get; set; } public double ModelTemperature { get; set; } From 7e6ab632cb2abaadb32faafe9d0030b6eeb8199e Mon Sep 17 00:00:00 2001 From: Eduardo Rezende Date: Mon, 18 Aug 2025 17:43:26 -0300 Subject: [PATCH 4/8] =?UTF-8?q?=E2=99=BB=EF=B8=8Frefactor:=20Update=20apps?= =?UTF-8?q?ettings.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removing AuthenticationHeader field because it's not editable for now --- appsettings.json | 1 - 1 file changed, 1 deletion(-) diff --git a/appsettings.json b/appsettings.json index 426c397..a757ea1 100644 --- a/appsettings.json +++ b/appsettings.json @@ -5,7 +5,6 @@ "Culture": "en-US", "OutputPath": "AutoDoc-Reports", "CompletionsUri": "http://localhost:1234/v1/chat/completions", - "AuthenticationHeader": "Bearer", "ApiKey": "your_api_key_here", "DelayMilliseconds": 20000, "ModelTemperature": 0.5, From 6e1816388f351f4754b4d120a3ed784f53634589 Mon Sep 17 00:00:00 2001 From: Eduardo Rezende Date: Mon, 18 Aug 2025 17:44:01 -0300 Subject: [PATCH 5/8] =?UTF-8?q?=E2=99=BB=EF=B8=8Frefactor:=20Update=20READ?= =?UTF-8?q?ME.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removing AuthenticationHeader field references because it's not editable for now --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 504c3b9..1e45afc 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ It leverages AI to transform commit history into meaningful documentation with c 4. **AI Integration** - Can use OpenAI APIs like (`/v1/chat/completions`). - - Can use custom APIs like (`v1/messages`) - Automatically retries failed requests and waits between calls to avoid memory overload. 5. **CSV Generation** @@ -40,7 +39,6 @@ All settings are handled in the `appsettings.json` file: "Culture": "en-US", "OutputPath": "AutoDoc-Reports", "CompletionsUri": "http://localhost:1234/v1/chat/completions", - "AuthenticationHeader": "Bearer", "ApiKey": "your_api_key_here", "DelayMilliseconds": 20000, "ModelTemperature": 0.5, @@ -55,7 +53,6 @@ All settings are handled in the `appsettings.json` file: - Culture β†’ Defines reporting culture/locale (e.g., pt-BR, en-US). - OutputPath β†’ Directory where daily CSV files are saved. - CompletionsUri β†’ API endpoint. -- AuthenticationHeader β†’ API Authentication method. - ApiKey β†’ API Key if applicable. - DelayMilliseconds β†’ Delay between requests (prevents RAM overload). - ModelTemperature β†’ Controls creativity of the model (0 = focused, 1 = creative). From e000e23f801cd3f954d0787193732d569e79c27f Mon Sep 17 00:00:00 2001 From: Eduardo Rezende Date: Mon, 18 Aug 2025 17:44:18 -0300 Subject: [PATCH 6/8] =?UTF-8?q?=E2=99=BB=EF=B8=8Frefactor:=20Update=20AppS?= =?UTF-8?q?ettings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removing AuthenticationHeader field because it's not editable for now --- src/Models/AppSettings.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Models/AppSettings.cs b/src/Models/AppSettings.cs index 890495e..9364766 100644 --- a/src/Models/AppSettings.cs +++ b/src/Models/AppSettings.cs @@ -12,7 +12,6 @@ public AppSettings() Culture = string.Empty; OutputPath = string.Empty; CompletionsUri = string.Empty; - AuthenticationHeader = string.Empty; ApiKey = string.Empty; } @@ -32,8 +31,6 @@ public AppSettings() public string CompletionsUri { get; set; } - public string AuthenticationHeader { get; set; } - public string ApiKey { get; set; } public int DelayMilliseconds { get; set; } From 3a453ef6d3e82ddab3278ba22accffb8aee3d035 Mon Sep 17 00:00:00 2001 From: Eduardo Rezende Date: Mon, 18 Aug 2025 17:54:11 -0300 Subject: [PATCH 7/8] =?UTF-8?q?=E2=9C=A8feat:=20Add=20LMClient=20api-key?= =?UTF-8?q?=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding api-key support for requests --- src/Clients/LMClient.cs | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/Clients/LMClient.cs b/src/Clients/LMClient.cs index 2e02385..a7519d4 100644 --- a/src/Clients/LMClient.cs +++ b/src/Clients/LMClient.cs @@ -2,6 +2,7 @@ using AutoDoc.Models; using System.Text.Json; using AutoDoc.Extensions; +using System.Net.Http.Headers; using Microsoft.Extensions.Logging; namespace AutoDoc.Clients @@ -93,11 +94,7 @@ private static async Task> CallModelAsync( { try { - var content = BuildRequestBody(commits, modelContext, appSettings); - - var response = await _httpClient.PostAsync(appSettings.CompletionsUri, content, ct); - response.EnsureSuccessStatusCode(); - + var response = await SendRequestAsync(commits, modelContext, appSettings, ct); var responseString = await response.Content.ReadAsStringAsync(ct); using var doc = JsonDocument.Parse(responseString); @@ -128,6 +125,29 @@ private static async Task> CallModelAsync( return result!; } + private static async Task SendRequestAsync( + IEnumerable commits, + string modelContext, + AppSettings appSettings, + CancellationToken ct) + { + if (commits is null || !commits.Any()) + return new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest); + + var content = BuildRequestBody(commits, modelContext, appSettings); + + var request = new HttpRequestMessage(HttpMethod.Post, appSettings.CompletionsUri) + { + Content = content + }; + + if (!string.IsNullOrWhiteSpace(appSettings.ApiKey)) + request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", appSettings.ApiKey); + + var response = await _httpClient.SendAsync(request, ct); + return response.EnsureSuccessStatusCode(); + } + private static StringContent BuildRequestBody( IEnumerable commits, string modelContext, From 5298c58fe27fbd8a0376da5e2aafd6937bc928f5 Mon Sep 17 00:00:00 2001 From: Eduardo Rezende Date: Mon, 18 Aug 2025 17:58:18 -0300 Subject: [PATCH 8/8] =?UTF-8?q?=E2=99=BB=EF=B8=8Frefactor:=20Update=20LMCl?= =?UTF-8?q?ient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improving variable name --- src/Clients/LMClient.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Clients/LMClient.cs b/src/Clients/LMClient.cs index a7519d4..6af5dbd 100644 --- a/src/Clients/LMClient.cs +++ b/src/Clients/LMClient.cs @@ -87,7 +87,7 @@ private static async Task> CallModelAsync( return []; var retriesCount = 1; - string message = string.Empty; + string json = string.Empty; IEnumerable? result = null; do @@ -98,19 +98,19 @@ private static async Task> CallModelAsync( var responseString = await response.Content.ReadAsStringAsync(ct); using var doc = JsonDocument.Parse(responseString); - message = doc.RootElement + json = doc.RootElement .GetProperty("choices")[0] .GetProperty("message") .GetProperty("content") .GetString()!; - result = JsonSerializer.Deserialize>(message, _jsonOptions); + result = JsonSerializer.Deserialize>(json, _jsonOptions); } catch (Exception ex) { logger?.LogError("Attempt: {Count}ΒΊ", retriesCount); logger?.LogError("{Error}", ex.Message); - logger?.LogError("{Json}", message); + logger?.LogError("{Json}", json); retriesCount++;