Skip to content

Commit 7c2f6e6

Browse files
committed
Put clipboard part into prefix
1 parent a2e45a6 commit 7c2f6e6

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Shared/Sources/Shared/CodeCompletionService/TabbyService.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ actor TabbyService {
88
case basic(username: String, password: String)
99
case customHeaderField(name: String, value: String)
1010
}
11-
11+
1212
let url: URL
1313
let temperature: Double
1414
let authorizationMode: AuthorizationMode
@@ -32,7 +32,11 @@ extension TabbyService: CodeCompletionServiceType {
3232
let clipboard = request.relevantCodeSnippets.map(\.content).joined(separator: "\n\n")
3333
let requestBody = RequestBody(
3434
language: request.language?.rawValue,
35-
segments: .init(prefix: prefix, suffix: suffix, clipboard: clipboard),
35+
segments: .init(
36+
prefix: clipboard + "\n\n" + prefix,
37+
suffix: suffix,
38+
clipboard: clipboard // it's seems to be ignored by Tabby
39+
),
3640
temperature: temperature,
3741
seed: nil
3842
)
@@ -89,7 +93,7 @@ extension TabbyService {
8993
let encoder = JSONEncoder()
9094
request.httpBody = try encoder.encode(requestBody)
9195
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
92-
96+
9397
switch authorizationMode {
9498
case let .basic(username, password):
9599
let data = "\(username):\(password)".data(using: .utf8)!
@@ -102,7 +106,7 @@ extension TabbyService {
102106
case .none:
103107
break
104108
}
105-
109+
106110
let (result, response) = try await URLSession.shared.data(for: request)
107111

108112
guard let response = response as? HTTPURLResponse else {
@@ -118,7 +122,7 @@ extension TabbyService {
118122
return body.choices.first?.text ?? ""
119123
} catch {
120124
dump(error)
121-
throw Error.decodeError(error)
125+
throw Error.decodeError(error)
122126
}
123127
}
124128
}

0 commit comments

Comments
 (0)