Skip to content

Commit acf14f1

Browse files
committed
Adjust interface
1 parent fd5c4aa commit acf14f1

4 files changed

Lines changed: 10 additions & 67 deletions

File tree

Pro

Submodule Pro updated from 52befe0 to e959ffc

Tool/Sources/ChatContextCollector/ChatContextCollector.swift

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,10 @@ import OpenAIService
33

44
public struct ChatContext {
55
public struct RetrievedContent {
6-
public enum Priority: Equatable, Comparable {
7-
case bottom
8-
case low
9-
case medium
10-
case high
11-
case top
12-
case custom(Int)
13-
14-
public var rawValue: Int {
15-
switch self {
16-
case .bottom:
17-
return 0
18-
case .low:
19-
return 400
20-
case .medium:
21-
return 600
22-
case .high:
23-
return 800
24-
case .top:
25-
return 1_000_000_000
26-
case let .custom(value):
27-
return value
28-
}
29-
}
30-
31-
public static func < (lhs: Self, rhs: Self) -> Bool {
32-
lhs.rawValue < rhs.rawValue
33-
}
34-
35-
public static func == (lhs: Self, rhs: Self) -> Bool {
36-
lhs.rawValue == rhs.rawValue
37-
}
38-
}
39-
406
public var content: String
41-
public var priority: Priority
7+
public var priority: Int
428

43-
public init(content: String, priority: Priority) {
9+
public init(content: String, priority: Int) {
4410
self.content = content
4511
self.priority = priority
4612
}
@@ -64,20 +30,6 @@ public struct ChatContext {
6430
}
6531
}
6632

67-
public func + (
68-
lhs: ChatContext.RetrievedContent.Priority,
69-
rhs: Int
70-
) -> ChatContext.RetrievedContent.Priority {
71-
.custom(lhs.rawValue + rhs)
72-
}
73-
74-
public func - (
75-
lhs: ChatContext.RetrievedContent.Priority,
76-
rhs: Int
77-
) -> ChatContext.RetrievedContent.Priority {
78-
.custom(lhs.rawValue - rhs)
79-
}
80-
8133
public protocol ChatContextCollector {
8234
func generateContext(
8335
history: [ChatMessage],

Tool/Sources/ChatContextCollectors/ActiveDocumentChatContextCollector/ActiveDocumentChatContextCollector.swift

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,8 @@ public final class ActiveDocumentChatContextCollector: ChatContextCollector {
2727
var removedCode = context
2828
removedCode.focusedContext = nil
2929
return .init(
30-
systemPrompt: "",
31-
retrievedContent: [
32-
.init(
33-
content: extractSystemPrompt(removedCode),
34-
priority: .high
35-
),
36-
],
30+
systemPrompt: extractSystemPrompt(removedCode),
31+
retrievedContent: [],
3732
functions: []
3833
)
3934
}
@@ -71,10 +66,8 @@ public final class ActiveDocumentChatContextCollector: ChatContextCollector {
7166
}
7267

7368
return .init(
74-
systemPrompt: "",
75-
retrievedContent: [
76-
.init(content: extractSystemPrompt(context), priority: .high)
77-
],
69+
systemPrompt: extractSystemPrompt(context),
70+
retrievedContent: [],
7871
functions: functions
7972
)
8073
}

Tool/Sources/ChatContextCollectors/ActiveDocumentChatContextCollector/LegacyActiveDocumentChatContextCollector.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ public struct LegacyActiveDocumentChatContextCollector: ChatContextCollector {
7878
}()
7979

8080
return .init(
81-
systemPrompt: "",
82-
retrievedContent: [
83-
.init(content: """
81+
systemPrompt: """
8482
Active Document Context:###
8583
Document Relative Path: \(relativePath)
8684
Selection Range Start: \
@@ -100,8 +98,8 @@ public struct LegacyActiveDocumentChatContextCollector: ChatContextCollector {
10098
.joined(separator: "\n") ?? "N/A"
10199
)
102100
###
103-
""", priority: .high),
104-
],
101+
""",
102+
retrievedContent: [],
105103
functions: []
106104
)
107105
}

0 commit comments

Comments
 (0)