Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
6ad2ead
Merge tag '0.24.0' into develop
intitni Sep 28, 2023
087a6fb
Merge tag '0.24.1' into develop
intitni Sep 29, 2023
41c95ff
Fix UI glitches created by Xcode 15
intitni Sep 29, 2023
8076180
Fix concurrency warning
intitni Sep 29, 2023
f342e00
Fix Swift 5.9 warnings
intitni Sep 29, 2023
7209f4d
Merge tag 'build-without-plus' into develop
intitni Oct 3, 2023
7f9ad17
Adjust package location
intitni Sep 28, 2023
bf4277c
Adjust package location
intitni Sep 29, 2023
f07f5e6
Update
intitni Oct 4, 2023
abc9a87
Implement basic structure of suggestion cheatsheet
intitni Oct 4, 2023
3a238ee
Merge branch 'feature/suggestion-cheatsheet-basic-structure' into dev…
intitni Oct 4, 2023
e164e8e
Migrate ChatGPTChatTab to use TCA, remove list inversion
intitni Oct 4, 2023
e5b3d8f
Make code blocks in chat horizontally scrollable
intitni Oct 4, 2023
d763796
Allow unwrapping code in code block
intitni Oct 4, 2023
c82867a
Merge branch 'feature/non-inverted-chat-history' into develop
intitni Oct 4, 2023
29240bc
Support chat tab reordering in UI
intitni Oct 4, 2023
e973924
Support persisting tab order
intitni Oct 5, 2023
146d72a
Merge branch 'feature/reorder-chat-tab' into develop
intitni Oct 5, 2023
91c6f81
Fix that new chat tab was not starting at the bottom
intitni Oct 5, 2023
5e534b3
Fix
intitni Oct 5, 2023
946e4b6
Prevent chat tab from being persisted after closed
intitni Oct 5, 2023
eebff15
Adjust the position of stop responding button
intitni Oct 5, 2023
d631234
Make generateContext async
intitni Oct 5, 2023
68575c2
ChatContextCollector
intitni Oct 5, 2023
81f723c
Update AutoManagedChatGPTMemory to handle retrieved content
intitni Oct 6, 2023
60f4ff5
Adjust ChatContext
intitni Oct 6, 2023
e2dea79
Move ActiveDocumentChatContextCollector to Tool
intitni Oct 9, 2023
fd5c4aa
Update
intitni Oct 9, 2023
acf14f1
Adjust interface
intitni Oct 10, 2023
8f7f16a
Update
intitni Oct 11, 2023
b088572
Add hard limit for retrieved content to use no more than half of max …
intitni Oct 11, 2023
85e6cf8
Adjust chat panel
intitni Oct 11, 2023
d506429
Update
intitni Oct 11, 2023
0ff8826
Merge branch 'feature/rag-base-project-scope' into develop
intitni Oct 11, 2023
3c66480
Make 2 toggles default to on
intitni Oct 11, 2023
4f51c84
Update
intitni Oct 11, 2023
00ff545
Adjust UI
intitni Oct 11, 2023
a00dd49
Update
intitni Oct 11, 2023
c1edf6d
Adjust minimum reply token count to avoid cut off when RAG is used
intitni Oct 11, 2023
e2adfe1
Update
intitni Oct 11, 2023
05e2241
Update TestPlan
intitni Oct 11, 2023
f59100e
Update
intitni Oct 11, 2023
2815396
Bump version to 0.25.0
intitni Oct 11, 2023
2627b41
Update appcast.xml
intitni Oct 11, 2023
3a08d0e
Merge branch 'release/0.25.0'
intitni Oct 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adjust ChatContext
  • Loading branch information
intitni committed Oct 6, 2023
commit 60f4ff596443211406ae55df033d8d03061bb348
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public final class ActiveDocumentChatContextCollector: ChatContextCollector {
var removedCode = context
removedCode.focusedContext = nil
return .init(
systemPrompt: [
systemPrompt: "",
retrievedContent: [
.init(
content: extractSystemPrompt(removedCode),
priority: .high
Expand Down Expand Up @@ -70,7 +71,8 @@ public final class ActiveDocumentChatContextCollector: ChatContextCollector {
}

return .init(
systemPrompt: [
systemPrompt: "",
retrievedContent: [
.init(content: extractSystemPrompt(context), priority: .high)
],
functions: functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public struct LegacyActiveDocumentChatContextCollector: ChatContextCollector {
}()

return .init(
systemPrompt: [
systemPrompt: "",
retrievedContent: [
.init(content: """
Active Document Context:###
Document Relative Path: \(relativePath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ public final class SystemInfoChatContextCollector: ChatContextCollector {
configuration: ChatGPTConfiguration
) -> ChatContext {
return .init(
systemPrompt: [
.init(
content: """
systemPrompt: """
Current Time: \(
Self.dateFormatter.string(from: Date())
) (You can use it to calculate time in another time zone)
""",
priority: .custom(999999)
),
],
retrievedContent: [],
functions: []
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ public final class WebChatContextCollector: ChatContextCollector {
links.isEmpty ? nil : QueryWebsiteFunction(),
]
return .init(
systemPrompt: [
.init(
content: "You prefer to answer questions with latest content on the internet.",
priority: .low
),
],
systemPrompt: "You prefer to answer questions with latest content on the internet.",
retrievedContent: [],
functions: functions.compactMap { $0 }
)
}
Expand Down
9 changes: 7 additions & 2 deletions Core/Sources/ChatService/DynamicContextController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,19 @@ final class DynamicContextController {
return contexts
}

let extraSystemPrompt = contexts
.map(\.systemPrompt)
.filter { !$0.isEmpty }
.joined(separator: "\n")

let contextPrompts = contexts
.flatMap(\.systemPrompt)
.flatMap(\.retrievedContent)
.filter { !$0.content.isEmpty }
.sorted { $0.priority > $1.priority }

let contextualSystemPrompt = """
\(language.isEmpty ? "" : "You must always reply in \(language)")
\(systemPrompt)
\(systemPrompt)\(extraSystemPrompt.isEmpty ? "" : "\n\(extraSystemPrompt)")
"""
await memory.mutateSystemPrompt(contextualSystemPrompt)
await memory.mutateRetrievedContent(contextPrompts.map(\.content))
Expand Down
2 changes: 1 addition & 1 deletion Pro
Submodule Pro updated from 9b5986 to 8dc924
24 changes: 15 additions & 9 deletions Tool/Sources/ChatContextCollector/ChatContextCollector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import OpenAIService

public struct ChatContext {
public struct RetrievedPrompt {
public struct RetrievedContent {
public enum Priority: Equatable, Comparable {
case low
case medium
Expand Down Expand Up @@ -40,29 +40,35 @@ public struct ChatContext {
}
}

public var systemPrompt: [RetrievedPrompt]
public var systemPrompt: String
public var retrievedContent: [RetrievedContent]
public var functions: [any ChatGPTFunction]
public init(systemPrompt: [RetrievedPrompt], functions: [any ChatGPTFunction]) {
public init(
systemPrompt: String,
retrievedContent: [RetrievedContent],
functions: [any ChatGPTFunction]
) {
self.systemPrompt = systemPrompt
self.retrievedContent = retrievedContent
self.functions = functions
}

public static var empty: Self {
.init(systemPrompt: [], functions: [])
.init(systemPrompt: "", retrievedContent: [], functions: [])
}
}

public func + (
lhs: ChatContext.RetrievedPrompt.Priority,
lhs: ChatContext.RetrievedContent.Priority,
rhs: Int
) -> ChatContext.RetrievedPrompt.Priority {
) -> ChatContext.RetrievedContent.Priority {
.custom(lhs.rawValue + rhs)
}

public func - (
lhs: ChatContext.RetrievedPrompt.Priority,
lhs: ChatContext.RetrievedContent.Priority,
rhs: Int
) -> ChatContext.RetrievedPrompt.Priority {
) -> ChatContext.RetrievedContent.Priority {
.custom(lhs.rawValue - rhs)
}

Expand Down