Skip to content

Commit 84fc1f3

Browse files
committed
Adjust function calling
1 parent 2ac4d4b commit 84fc1f3

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Tool/Sources/ChatContextCollectors/ActiveDocumentChatContextCollector/ActiveDocumentChatContextCollector.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,17 @@ public final class ActiveDocumentChatContextCollector: ChatContextCollector {
4646
var functions = [any ChatGPTFunction]()
4747

4848
if !isSensitive {
49+
let contextLineRange: String = {
50+
if let range = context.focusedContext?.codeRange {
51+
return " from \(range.start.line + 1) to \(range.end.line + 1)"
52+
}
53+
return ""
54+
}()
55+
4956
var functionPrompt = """
5057
ONLY call it when one of the following conditions are satisfied:
51-
- the user ask you about specific line from the latest message, \
52-
which is not included in the focused range.
58+
- the user explicitly ask you about specific line of code, \
59+
but the line was NOT in the focused range \(contextLineRange).
5360
"""
5461

5562
if let annotations = context.focusedContext?.otherLineAnnotations,

0 commit comments

Comments
 (0)