forked from github/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGitHubCopilotConversationService.swift
More file actions
64 lines (51 loc) · 3.33 KB
/
GitHubCopilotConversationService.swift
File metadata and controls
64 lines (51 loc) · 3.33 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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,
ignoredSkills: request.ignoredSkills,
references: request.references ?? [],
model: request.model)
}
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,
ignoredSkills: request.ignoredSkills,
references: request.references ?? [],
model: request.model)
}
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)
}
public func templates(workspace: WorkspaceInfo) async throws -> [ChatTemplate]? {
guard let service = await serviceLocator.getService(from: workspace) else { return nil }
return try await service.templates()
}
public func models(workspace: WorkspaceInfo) async throws -> [CopilotModel]? {
guard let service = await serviceLocator.getService(from: workspace) else { return nil }
return try await service.models()
}
}