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