-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathGitHubCopilotConversationService.swift
More file actions
46 lines (34 loc) · 2.28 KB
/
GitHubCopilotConversationService.swift
File metadata and controls
46 lines (34 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import CopilotForXcodeKit
import Foundation
import ConversationServiceProvider
import BuiltinExtension
public final class GitHubCopilotConversationService: ConversationServiceType {
private let serviceLocator: ServiceLocator
init(serviceLocator: ServiceLocator) {
self.serviceLocator = serviceLocator
}
public func createConversation(_ request: ConversationRequest, workspace: WorkspaceInfo) async throws {
guard let service = await serviceLocator.getService(from: workspace) else { return }
return try await service.createConversation(request.content,
workDoneToken: request.workDoneToken,
workspaceFolder: request.workspaceFolder,
doc: nil,
skills: request.skills)
}
public func createTurn(with conversationId: String, request: ConversationRequest, workspace: WorkspaceInfo) async throws {
guard let service = await serviceLocator.getService(from: workspace) else { return }
return try await service.createTurn(request.content, workDoneToken: request.workDoneToken, conversationId: conversationId, doc: nil)
}
public func cancelProgress(_ workDoneToken: String, workspace: WorkspaceInfo) async throws {
guard let service = await serviceLocator.getService(from: workspace) else { return }
await service.cancelProgress(token: workDoneToken)
}
public func rateConversation(turnId: String, rating: ConversationRating, workspace: WorkspaceInfo) async throws {
guard let service = await serviceLocator.getService(from: workspace) else { return }
try await service.rateConversation(turnId: turnId, rating: rating)
}
public func copyCode(request: CopyCodeRequest, workspace: WorkspaceInfo) async throws {
guard let service = await serviceLocator.getService(from: workspace) else { return }
try await service.copyCode(turnId: request.turnId, codeBlockIndex: request.codeBlockIndex, copyType: request.copyType, copiedCharacters: request.copiedCharacters, totalCharacters: request.totalCharacters, copiedText: request.copiedText)
}
}