Skip to content

Commit

Permalink
persist context when cutting context
Browse files Browse the repository at this point in the history
  • Loading branch information
Sun Hyuk Ahn committed Nov 13, 2023
1 parent f9aa114 commit b77b504
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
16 changes: 10 additions & 6 deletions voice/voice-ai/Voice AI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,16 @@
A46B5A8C2AE73D5C00C874ED /* DashboardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD0D13392ADA73B300031EDD /* DashboardView.swift */; };
A4C5E8632AF6BF8E00B273E4 /* Store.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22CC4D7D2AF3C1C10072EC39 /* Store.swift */; };
A4C5E8642AF6BF9100B273E4 /* Persistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22CC4D792AF3AD900072EC39 /* Persistence.swift */; };
A4E2080C2B02B56C000909C5 /* AppConfig.plist in Resources */ = {isa = PBXBuildFile; fileRef = A4E2080B2B02B56C000909C5 /* AppConfig.plist */; };
A4E2080D2B02B56C000909C5 /* AppConfig.plist in Resources */ = {isa = PBXBuildFile; fileRef = A4E2080B2B02B56C000909C5 /* AppConfig.plist */; };
A4E2080E2B02B56C000909C5 /* AppConfig.plist in Resources */ = {isa = PBXBuildFile; fileRef = A4E2080B2B02B56C000909C5 /* AppConfig.plist */; };
A4E2080F2B02B56C000909C5 /* AppConfig.plist in Resources */ = {isa = PBXBuildFile; fileRef = A4E2080B2B02B56C000909C5 /* AppConfig.plist */; };
B31CDCE32AFC561C00AB39EE /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B3BA792AFB40A300D8F8C6 /* Theme.swift */; };
B31CDCE42AFC565400AB39EE /* ThemeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B346DF772AF562020023FC87 /* ThemeManager.swift */; };
B31CDCE52AFC565800AB39EE /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B3BA792AFB40A300D8F8C6 /* Theme.swift */; };
B346DF782AF562020023FC87 /* ThemeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B346DF772AF562020023FC87 /* ThemeManager.swift */; };
B36367562AFC69F2000409FC /* RandomFactTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B31CDCE62AFC644D00AB39EE /* RandomFactTests.swift */; };
B36367572AFC6A04000409FC /* MockGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7F1150D2AF825F700BC191C /* MockGenerator.swift */; };
B38ADB9D2AFE0A0F006BDC93 /* AppConfig.plist in Resources */ = {isa = PBXBuildFile; fileRef = F72708412AFD672E000DE81D /* AppConfig.plist */; };
B3C083B32AF1BADB0069232C /* MessageContextTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3C083B22AF1BADB0069232C /* MessageContextTests.swift */; };
B3D0A3442AF29B1B00E8B0DA /* MockNetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3D0A3432AF29B1B00E8B0DA /* MockNetworkService.swift */; };
B91681282AFBA3A80006E463 /* ReviewRequester.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9B331A02AFB803500F6A9C9 /* ReviewRequester.swift */; };
Expand Down Expand Up @@ -158,7 +161,6 @@
F67E43342AFAC16C001B72CD /* Sentry in Frameworks */ = {isa = PBXBuildFile; productRef = F67E43332AFAC16C001B72CD /* Sentry */; };
F723CC1F2AFECE2000B2A23A /* TextToSpeechConverterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F723CC1E2AFECE2000B2A23A /* TextToSpeechConverterTests.swift */; };
F723CC212AFEFFA400B2A23A /* MockAVSpeechSynthesizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = F723CC202AFEFFA400B2A23A /* MockAVSpeechSynthesizer.swift */; };
F72708422AFD672E000DE81D /* AppConfig.plist in Resources */ = {isa = PBXBuildFile; fileRef = F72708412AFD672E000DE81D /* AppConfig.plist */; };
F7C16FE82AFC576000D11529 /* ThemeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B346DF772AF562020023FC87 /* ThemeManager.swift */; };
F7F115052AF8173300BC191C /* SpeechRecognitionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7F114F52AF8172800BC191C /* SpeechRecognitionTests.swift */; };
F7F115062AF8173300BC191C /* StringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7F114F72AF8172800BC191C /* StringTests.swift */; };
Expand Down Expand Up @@ -230,6 +232,7 @@
A46B5A632AE73B9D00C874ED /* sunUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = sunUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
A46B5A672AE73B9D00C874ED /* sunUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = sunUITests.swift; sourceTree = "<group>"; };
A46B5A692AE73B9D00C874ED /* sunUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = sunUITestsLaunchTests.swift; sourceTree = "<group>"; };
A4E2080B2B02B56C000909C5 /* AppConfig.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = AppConfig.plist; sourceTree = "<group>"; };
B31CDCE62AFC644D00AB39EE /* RandomFactTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RandomFactTests.swift; sourceTree = "<group>"; };
B346DF772AF562020023FC87 /* ThemeManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeManager.swift; sourceTree = "<group>"; };
B3B3BA792AFB40A300D8F8C6 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -281,7 +284,6 @@
F61049092AF02D820087F745 /* OpenAIStreamService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenAIStreamService.swift; sourceTree = "<group>"; };
F723CC1E2AFECE2000B2A23A /* TextToSpeechConverterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextToSpeechConverterTests.swift; sourceTree = "<group>"; };
F723CC202AFEFFA400B2A23A /* MockAVSpeechSynthesizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockAVSpeechSynthesizer.swift; sourceTree = "<group>"; };
F72708412AFD672E000DE81D /* AppConfig.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = AppConfig.plist; sourceTree = "<group>"; };
F7F114F52AF8172800BC191C /* SpeechRecognitionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpeechRecognitionTests.swift; sourceTree = "<group>"; };
F7F114F62AF8172800BC191C /* PermissionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PermissionTests.swift; sourceTree = "<group>"; };
F7F114F72AF8172800BC191C /* StringTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -573,7 +575,7 @@
CD0D13402ADA73B400031EDD /* Preview Content */,
22CC4D752AF3AC300072EC39 /* Products.storekit */,
22A9883A2AF8FE0D00A32B1A /* SyncedProducts.storekit */,
F72708412AFD672E000DE81D /* AppConfig.plist */,
A4E2080B2B02B56C000909C5 /* AppConfig.plist */,
);
path = x;
sourceTree = "<group>";
Expand Down Expand Up @@ -820,6 +822,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A4E2080F2B02B56C000909C5 /* AppConfig.plist in Resources */,
A46B5A542AE73B9D00C874ED /* Preview Assets.xcassets in Resources */,
A4680D9F2AE9C8A600F5F8ED /* beep.mp3 in Resources */,
A46B5A782AE73CD300C874ED /* Dotrice-Bold.otf in Resources */,
Expand Down Expand Up @@ -849,7 +852,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F72708422AFD672E000DE81D /* AppConfig.plist in Resources */,
A4E2080C2B02B56C000909C5 /* AppConfig.plist in Resources */,
CD0D13422ADA73B400031EDD /* Preview Assets.xcassets in Resources */,
22A9883B2AF8FE0D00A32B1A /* SyncedProducts.storekit in Resources */,
CD0D133E2ADA73B400031EDD /* Assets.xcassets in Resources */,
Expand All @@ -868,14 +871,15 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B38ADB9D2AFE0A0F006BDC93 /* AppConfig.plist in Resources */,
A4E2080D2B02B56C000909C5 /* AppConfig.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
CD0D13502ADA73B400031EDD /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A4E2080E2B02B56C000909C5 /* AppConfig.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion voice/voice-ai/x/OpenAIService/OpenAIStreamService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class OpenAIStreamService: NSObject, URLSessionDataDelegate {
"stream": true
]
print("[OpenAI] Model used: \(model); Minutes elaspsed: \(miutesElasped)")

print("[OpenAI] sent \(body)")
// Validate the URL
guard let url = URL(string: "https://api.openai.com/v1/chat/completions") else {
Expand Down
4 changes: 2 additions & 2 deletions voice/voice-ai/x/SpeechRecognition/SpeechRecognition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ class SpeechRecognition: NSObject, ObservableObject, SpeechRecognitionProtocol {
// ensure streams that do not have a whitespace in front are appended to the previous one (part of the previous stream)
if !initialFlush {
if self.speechDelimitingPunctuations.contains(currWord.last!) || buf.count == self.initialCapacity {
print("############ INITIAL FLUSH")
flushBuf()
initialFlush = true
}
Expand All @@ -367,7 +366,8 @@ class SpeechRecognition: NSObject, ObservableObject, SpeechRecognitionProtocol {
}
}

let limitedConversation = OpenAIUtils.limitConversationContext(conversation, charactersCount: 512)
var limitedConversation = OpenAIUtils.limitConversationContext(conversation, charactersCount: 512)
limitedConversation.append(contentsOf: OpenAIStreamService.setConversationContext())
pendingOpenAIStream?.query(conversation: limitedConversation)
}

Expand Down

0 comments on commit b77b504

Please sign in to comment.