CHS Minutes, AGM, SGM - Old
Minutes
- For SGM we don’t have to do anything
New & simple way to simplify Minutes using AI
- On MinutesBookDetails we will have an attractive popover Enhance with AI
- Once user click on this we have to navigate on form to upload the Minutes PDF, one info msg we will give on this form, Pleas download minutes pdf from details page & upload it
- We will also have check box which give user to Apply Modification, in this we will have values
- Grammar Correction → “Grammar Correction”
- Summarize Notes → “Summarize the meeting minutes into short points for quick reference.”
- Expand Notes → “Summarize the meeting minutes into short points for quick reference.”
- Grammar Correction check box will be default selected
- Once user upload pdf we will save in path
- Now we will send uploaded pdf, selected Apply Modification value, & default Modifiction value that is grammer correction to AI
- AI will return the html format of given PDF + Modified version, Now this will be saved in path & given to user
- User can open the html file & just copy it in word file
- If again they want some more changes in revised version, they can convert to PDF & reupload it
Service Helper method
// Default modification always applied
string defaultPrompts = @"Apply the following modification:
Generate a professional and formal version of the meeting minutes in structured paragraphs.
Correct grammar, spelling, and sentence structure to make the minutes polished.
Expand the meeting minutes into detailed descriptive paragraphs with complete context.";
// Get user-selected modification type
// string userPrompts = selectedPrompts switch
// {
// "Summarize Notes" => "Summarize the meeting minutes into short points for quick reference.",
// "Expand Notes" => "Expand the meeting minutes into detailed descriptive paragraphs with complete context.",
// _ => "NA" // Default for None
// };
// Combine both instructions
var instructions = new StringBuilder();
instructions.AppendLine(defaultPrompts);
// if (userPrompts != "NA")
// {
// instructions.AppendLine(userPrompts);
// }
// Define system prompt
// var systemPrompt = @"You are an assistant that enhances cooperative housing society meeting minutes.
// Always return polished, professional text in HTML format suitable for conversion to Word.
// Follow these formatting rules:
// You are an assistant that enhances cooperative housing society meeting minutes.
// - Preserve the **original formatting** of the PDF exactly, including tables, spacing, and alignment.
// - Only make the following modifications:
// 1. Correct grammar and spelling.
// 2. Expand notes if requested.
// 3. Summarize notes if requested.
// - Do not change table structures or layout.
// - Return the output in **HTML format** suitable for Word, but mimic the PDF layout exactly.
// - Avoid adding extra spaces, bullet points, or new tables.
// ";
var systemPrompt = @"You are an assistant that enhances cooperative housing society meeting minutes. Always return polished, professional text in html format suitable for conversion to Word.";
// Upload PDF to OpenAI
var pdfFilePath = "\\CHSReports\\Reports\\" + dbname + "\\" + "MC_Minutes.pdf"; ;
using var multipartForm = new MultipartFormDataContent
{
{ new StringContent("assistants"), "purpose" }, // purpose must be "assistants" as we have to use this file for next call
{ new StreamContent(File.OpenRead(pdfFilePath)), "file", Path.GetFileName(pdfFilePath) }
};
var uploadResponse = await _OpenAIHttpClient.PostAsync("v1/files", multipartForm);
uploadResponse.EnsureSuccessStatusCode();
var uploadJson = await uploadResponse.Content.ReadFromJsonAsync<OpenAIFileResponse>();
var fileId = uploadJson!.id?.ToString();
var requestBody = new
{
model = _model,
input = new object[]
{
new
{
role = "system",
content = systemPrompt
},
new
{
role = "user",
content = new object[]
{
new { type = "input_text", text = instructions.ToString() },
new { type = "input_file", file_id = fileId }
}
}
}
};
// Call OpenAI endpoint
var response = await _OpenAIHttpClient.PostAsJsonAsync("v1/responses", requestBody);
if (!response.IsSuccessStatusCode)
{
var error = await response.Content.ReadAsStringAsync();
Console.WriteLine($"OpenAI API Error: {error}");//why this need to do ?
return string.Empty;
}
var openAIResponse = await response.Content.ReadFromJsonAsync<OpenAIResponseV2>();
if (openAIResponse?.output?.Count > 0 && openAIResponse.output[0].content?.Count != null)
{
var htmlcode = openAIResponse.output[1].content[0].text.Trim();
// htmlcode = htmlmessage.content.Trim();
// --- Direct File Saving Logic ---
Random rnd = new();
var randomfilename = $"{rnd.Next(1000000000)}.html";
string pathdirname = $"\\CHSReports\\Reports\\{dbname}";
if (!Directory.Exists(pathdirname))
{
Directory.CreateDirectory(pathdirname);
}
string pathname = $"{pathdirname}\\{randomfilename}";
await File.WriteAllTextAsync(pathname, htmlcode);
return randomfilename; // Return the name of the file you just saved
}
await _OpenAIHttpClient.DeleteAsync($"v1/files/{fileId}");
return string.Empty;SGM & AGM
- Already in minutes menu we have option to create AGM & SGM
- Only in download PDF we have structure for minutes but currently allowing for AGM & SGM