feat: implement OpenAI API integration for generating meeting notes

This commit is contained in:
Owen Gretzinger
2025-07-10 20:15:32 -04:00
parent a99e080324
commit fd6f842aa3
+18 -18
View File
@@ -2,6 +2,7 @@
// Handles AI-powered note generation using OpenAI // Handles AI-powered note generation using OpenAI
import Foundation import Foundation
import OpenAI
/// Generates meeting notes using OpenAI API /// Generates meeting notes using OpenAI API
class NotesGenerator { class NotesGenerator {
@@ -21,30 +22,29 @@ class NotesGenerator {
userBlurb: String, userBlurb: String,
systemPrompt: String) async throws -> String { systemPrompt: String) async throws -> String {
// TODO: Implement OpenAI API integration guard let apiKey = KeychainHelper.shared.get(forKey: "openAIKey"), !apiKey.isEmpty else {
// For now, return a placeholder throw NSError(domain: "NotesGenerator", code: 1, userInfo: [NSLocalizedDescriptionKey: "OpenAI API key not configured"])
}
// Simulate API delay let openAI = OpenAI(apiToken: apiKey)
try await Task.sleep(nanoseconds: 2_000_000_000)
// Placeholder response // Compose system prompt with user blurb wrapped in XML tags for clarity
return """ let systemContent = "\(systemPrompt)\n\n<user_blurb>\n\(userBlurb)\n</user_blurb>"
# Meeting Notes let systemMessage = ChatQuery.ChatCompletionMessageParam(role: .system, content: systemContent)!
## Summary // Provide the model with structured XML-tagged input variables for improved parsing
This is a placeholder for AI-generated meeting notes. let userContent = "<task>Generate concise and well-structured meeting notes using the information below.</task>\n\n<transcript>\n\(transcript)\n</transcript>\n\n<user_notes>\n\(userNotes)\n</user_notes>"
let userMessage = ChatQuery.ChatCompletionMessageParam(role: .user, content: userContent)!
## Key Points let query = ChatQuery(messages: [systemMessage, userMessage], model: .gpt4_1_mini)
- Transcript length: \(transcript.count) characters
- User notes provided: \(!userNotes.isEmpty)
## Action Items let result = try await openAI.chats(query: query)
- Implement OpenAI API integration
- Add proper prompt engineering
## Next Steps guard let generatedNotes = result.choices.first?.message.content else {
Once OpenAI API is integrated, this will provide comprehensive meeting notes based on the transcript and any additional context provided. throw NSError(domain: "NotesGenerator", code: 2, userInfo: [NSLocalizedDescriptionKey: "Failed to generate notes"])
""" }
return generatedNotes
} }
/// Validates if OpenAI API key is configured /// Validates if OpenAI API key is configured