Skip to content

Commit 31a12e9

Browse files
committed
Update get code function
1 parent bbf2bd2 commit 31a12e9

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

Tool/Sources/ChatContextCollectors/ActiveDocumentChatContextCollector/ActiveDocumentChatContextCollector.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ public final class ActiveDocumentChatContextCollector: ChatContextCollector {
4545
var functions = [any ChatGPTFunction]()
4646

4747
if !isSensitive {
48-
functions.append(GetCodeCodeAroundLineFunction(contextCollector: self))
48+
functions.append(GetCodeCodeAroundLineFunction(
49+
contextCollector: self,
50+
additionalDescription: "You already have the code in focusing range, don't get it again!"
51+
))
4952
}
5053

5154
return .init(

Tool/Sources/ChatContextCollectors/ActiveDocumentChatContextCollector/Functions/GetCodeCodeAroundLineFunction.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct GetCodeCodeAroundLineFunction: ChatGPTFunction {
3232
}
3333

3434
var description: String {
35-
"Get the code at the given line. You must ONLY call it when the user give you a specific line or the user ask about an out of scope annotation."
35+
"Get the code at the given line. You must ONLY call it when the user give you a specific line or the user ask about an out of scope annotation. \n\(additionalDescription)"
3636
}
3737

3838
var argumentSchema: JSONSchemaValue { [
@@ -47,9 +47,12 @@ struct GetCodeCodeAroundLineFunction: ChatGPTFunction {
4747
] }
4848

4949
weak var contextCollector: ActiveDocumentChatContextCollector?
50+
51+
let additionalDescription: String
5052

51-
init(contextCollector: ActiveDocumentChatContextCollector) {
53+
init(contextCollector: ActiveDocumentChatContextCollector, additionalDescription: String = "") {
5254
self.contextCollector = contextCollector
55+
self.additionalDescription = additionalDescription
5356
}
5457

5558
func prepare(reportProgress: @escaping (String) async -> Void) async {

0 commit comments

Comments
 (0)