-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathGitHubCopilotConversationService.swift
More file actions
80 lines (63 loc) · 4.09 KB
/
GitHubCopilotConversationService.swift
File metadata and controls
80 lines (63 loc) · 4.09 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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: workspace.projectURL.path,
doc: nil,
skills: request.skills,
ignoredSkills: request.ignoredSkills,
references: request.references ?? [],
model: request.model,
turns: request.turns)
}
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,
workspaceFolder: workspace.projectURL.path)
}
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()
}
public func notifyDidChangeWatchedFiles(_ event: DidChangeWatchedFilesEvent, workspace: WorkspaceInfo) async throws {
guard let service = await serviceLocator.getService(from: workspace) else {
return
}
return try await service.notifyDidChangeWatchedFiles(.init(workspaceUri: event.workspaceUri, changes: event.changes))
}
public func agents(workspace: WorkspaceInfo) async throws -> [ChatAgent]? {
guard let service = await serviceLocator.getService(from: workspace) else { return nil }
return try await service.agents()
}
}