Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
e11d290
Merge tag '0.26.0' into develop
intitni Oct 22, 2023
62a6e85
Disable hit test when a chat panel tab is not active
intitni Oct 22, 2023
27ad97c
Update
intitni Oct 30, 2023
a9f3f48
Merge branch 'feature/retrieve-from-active-document' into develop
intitni Oct 30, 2023
ad9c008
Add new scope @sense
intitni Oct 30, 2023
5bdaf24
Update instruction
intitni Oct 30, 2023
ddbfece
Add settings for scopes
intitni Oct 31, 2023
3f25cc5
Adjust UI
intitni Oct 31, 2023
e1f4b54
Update UI
intitni Oct 31, 2023
2b5d950
Update to setup scope according to settings
intitni Oct 31, 2023
f528d9a
Support changing default scopes in chat panel
intitni Oct 31, 2023
956f712
Add Scope enum to represent scopes
intitni Oct 31, 2023
39b387d
Support changing model according to scopes
intitni Oct 31, 2023
d55b05c
Support persisting scopes of chat panel
intitni Oct 31, 2023
5f71a97
Update
intitni Oct 31, 2023
67a9eb0
Merge branch 'feature/search-scope' into develop
intitni Oct 31, 2023
4b34f20
Update
intitni Nov 2, 2023
403a918
Add new logger
intitni Nov 2, 2023
c03ce88
Fix tests
intitni Nov 2, 2023
4158c6b
Add ContextAwarePromptToCodeService
intitni Nov 3, 2023
f47d2d3
Update
intitni Nov 6, 2023
582bdc4
Update
intitni Nov 6, 2023
5848281
Merge branch 'feature/prompt-to-code-with-chat-context-support' into …
intitni Nov 6, 2023
4209f86
Make chat window title bar and traffic light button bigger
intitni Nov 2, 2023
e1cdd69
Merge branch 'feature/adjust-chat-window-title-bar-ui' into develop
intitni Nov 6, 2023
0167734
Update focus code finder to return more info about contexts
intitni Nov 8, 2023
8923f39
Prevent variable declaration being used as code range
intitni Nov 8, 2023
585df56
Support proService clean up
intitni Nov 8, 2023
4740bae
Add keys
intitni Nov 8, 2023
1f3650a
Reset to use old prompt to code service
intitni Nov 8, 2023
fd84744
Update
intitni Nov 8, 2023
4a39591
Add new OpenAI model
intitni Nov 8, 2023
7dc23dc
Merge branch 'feature/add-new-models' into develop
intitni Nov 8, 2023
18a5b34
Adjust implementation of chat panel
intitni Nov 9, 2023
ab97bad
Tweak pin to bottom behavior of chat panel
intitni Nov 9, 2023
4974b20
Merge branch 'feature/chat-panel-improvement' into develop
intitni Nov 9, 2023
8330640
Move context system prompt to right next to the latest message
intitni Nov 9, 2023
6938c9f
Merge branch 'feature/adjust-position-of-context-system-prompt' into …
intitni Nov 9, 2023
309c70f
Track scroll event to disable pin to bottom
intitni Nov 9, 2023
e6940a5
Merge branch 'feature/use-scroll-event-to-disable-pin-to-bottom' into…
intitni Nov 9, 2023
651d29b
Bump Github Copilot to 1.11.4
intitni Nov 9, 2023
1cf2781
Bump Codeium to 1.4.15
intitni Nov 9, 2023
93c5404
Fix a crash that calls dropLast with a negative number
intitni Nov 9, 2023
228b2b2
Update
intitni Nov 9, 2023
ee2aefb
Update
intitni Nov 9, 2023
9b0b4bc
Fix chat panel interfere
intitni Nov 9, 2023
65e603e
Select the first chat tab after restoring
intitni Nov 9, 2023
ab3be0d
Fix that prompt to code can open at launch
intitni Nov 9, 2023
78809ef
Update
intitni Nov 9, 2023
02ae983
Bump version to 0.27.0
intitni Nov 9, 2023
aac6509
Add sense scope to auto completion
intitni Nov 9, 2023
d0910a2
Simplify implementation
intitni Nov 9, 2023
17ce115
Fix that overriding model not overriding max token and min reply token
intitni Nov 9, 2023
bb3d534
Update
intitni Nov 9, 2023
f0b2a24
Update
intitni Nov 9, 2023
e54c85f
Update
intitni Nov 9, 2023
12bc66b
Update
intitni Nov 9, 2023
21985b9
Update appcast.xml
intitni Nov 9, 2023
fa7dc18
Merge branch 'release/0.27.0'
intitni Nov 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Core/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ let package = Package(
.product(name: "OpenAIService", package: "Tool"),
.product(name: "AppMonitoring", package: "Tool"),
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
]
].pro([
"ProService",
])
),
.testTarget(name: "PromptToCodeServiceTests", dependencies: ["PromptToCodeService"]),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public final class SystemInfoChatContextCollector: ChatContextCollector {

public func generateContext(
history: [ChatMessage],
scopes: Set<String>,
scopes: Set<ChatContext.Scope>,
content: String,
configuration: ChatGPTConfiguration
) -> ChatContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public final class WebChatContextCollector: ChatContextCollector {

public func generateContext(
history: [ChatMessage],
scopes: Set<String>,
scopes: Set<ChatContext.Scope>,
content: String,
configuration: ChatGPTConfiguration
) -> ChatContext {
guard scopes.contains("web") || scopes.contains("w") else { return .empty }
guard scopes.contains(.web) else { return .empty }
let links = Self.detectLinks(from: history) + Self.detectLinks(from: content)
let functions: [(any ChatGPTFunction)?] = [
SearchFunction(maxTokens: configuration.maxTokens),
Expand Down
36 changes: 36 additions & 0 deletions Core/Sources/ChatGPTChatTab/Chat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ struct Chat: ReducerProtocol {
case observeIsReceivingMessageChange
case observeSystemPromptChange
case observeExtraSystemPromptChange
case observeDefaultScopesChange

case historyChanged
case isReceivingMessageChanged
case systemPromptChanged
case extraSystemPromptChanged
case defaultScopesChanged

case chatMenu(ChatMenu.Action)
}
Expand All @@ -68,6 +70,7 @@ struct Chat: ReducerProtocol {
case observeIsReceivingMessageChange(UUID)
case observeSystemPromptChange(UUID)
case observeExtraSystemPromptChange(UUID)
case observeDefaultScopesChange(UUID)
}

var body: some ReducerProtocol<State, Action> {
Expand Down Expand Up @@ -131,6 +134,7 @@ struct Chat: ReducerProtocol {
await send(.observeIsReceivingMessageChange)
await send(.observeSystemPromptChange)
await send(.observeExtraSystemPromptChange)
await send(.observeDefaultScopesChange)
}

case .observeHistoryChange:
Expand Down Expand Up @@ -198,6 +202,22 @@ struct Chat: ReducerProtocol {
}
}.cancellable(id: CancelID.observeExtraSystemPromptChange(id), cancelInFlight: true)

case .observeDefaultScopesChange:
return .run { send in
let stream = AsyncStream<Void> { continuation in
let cancellable = service.$defaultScopes
.sink { _ in
continuation.yield()
}
continuation.onTermination = { _ in
cancellable.cancel()
}
}
for await _ in stream {
await send(.defaultScopesChanged)
}
}.cancellable(id: CancelID.observeDefaultScopesChange(id), cancelInFlight: true)

case .historyChanged:
state.history = service.chatHistory.map { message in
.init(
Expand Down Expand Up @@ -250,6 +270,10 @@ struct Chat: ReducerProtocol {
state.chatMenu.extraSystemPrompt = service.extraSystemPrompt
return .none

case .defaultScopesChanged:
state.chatMenu.defaultScopes = service.defaultScopes
return .none

case .binding:
return .none

Expand All @@ -266,6 +290,7 @@ struct ChatMenu: ReducerProtocol {
var extraSystemPrompt: String = ""
var temperatureOverride: Double? = nil
var chatModelIdOverride: String? = nil
var defaultScopes: Set<ChatService.Scope> = []
}

enum Action: Equatable {
Expand All @@ -274,6 +299,8 @@ struct ChatMenu: ReducerProtocol {
case temperatureOverrideSelected(Double?)
case chatModelIdOverrideSelected(String?)
case customCommandButtonTapped(CustomCommand)
case resetDefaultScopesButtonTapped
case toggleScope(ChatService.Scope)
}

let service: ChatService
Expand Down Expand Up @@ -304,6 +331,15 @@ struct ChatMenu: ReducerProtocol {
return .run { _ in
try await service.handleCustomCommand(command)
}

case .resetDefaultScopesButtonTapped:
return .run { _ in
service.resetDefaultScopes()
}
case let .toggleScope(scope):
return .run { _ in
service.defaultScopes.formSymmetricDifference([scope])
}
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions Core/Sources/ChatGPTChatTab/ChatContextMenu.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import AppKit
import ChatService
import ComposableArchitecture
import SharedUIComponents
import SwiftUI
Expand Down Expand Up @@ -30,6 +31,7 @@ struct ChatContextMenu: View {

chatModel
temperature
defaultScopes

Divider()

Expand Down Expand Up @@ -153,6 +155,34 @@ struct ChatContextMenu: View {
}
}

@ViewBuilder
var defaultScopes: some View {
Menu("Default Scopes") {
WithViewStore(store, observe: \.defaultScopes) { viewStore in
Button(action: {
store.send(.resetDefaultScopesButtonTapped)
}) {
Text("Reset Default Scopes")
}

Divider()

ForEach(ChatService.Scope.allCases, id: \.rawValue) { value in
Button(action: {
viewStore.send(.toggleScope(value))
}) {
HStack {
Text("@" + value.rawValue)
if viewStore.state.contains(value) {
Image(systemName: "checkmark")
}
}
}
}
}
}
}

var customCommandMenu: some View {
Menu("Custom Commands") {
ForEach(
Expand Down
9 changes: 8 additions & 1 deletion Core/Sources/ChatGPTChatTab/ChatGPTChatTab.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import ChatContextCollector
import ChatService
import ChatTab
import CodableWrappers
import Combine
import ComposableArchitecture
import Foundation
Expand All @@ -21,6 +23,7 @@ public class ChatGPTChatTab: ChatTab {
var configuration: OverridingChatGPTConfiguration.Overriding
var systemPrompt: String
var extraSystemPrompt: String
var defaultScopes: Set<ChatContext.Scope>?
}

struct Builder: ChatTabBuilder {
Expand Down Expand Up @@ -65,7 +68,8 @@ public class ChatGPTChatTab: ChatTab {
history: await service.memory.history,
configuration: service.configuration.overriding,
systemPrompt: service.systemPrompt,
extraSystemPrompt: service.extraSystemPrompt
extraSystemPrompt: service.extraSystemPrompt,
defaultScopes: service.defaultScopes
)
return (try? JSONEncoder().encode(state)) ?? Data()
}
Expand All @@ -79,6 +83,9 @@ public class ChatGPTChatTab: ChatTab {
tab.service.configuration.overriding = state.configuration
tab.service.mutateSystemPrompt(state.systemPrompt)
tab.service.mutateExtraSystemPrompt(state.extraSystemPrompt)
if let scopes = state.defaultScopes {
tab.service.defaultScopes = scopes
}
await tab.service.memory.mutateHistory { history in
history = state.history
}
Expand Down
Loading