Skip to content

Commit 0414783

Browse files
committed
Merge branch 'release/0.7.0'
2 parents 8674cd9 + 7472ad0 commit 0414783

File tree

9 files changed

+54
-24
lines changed

9 files changed

+54
-24
lines changed

Core/Sources/CodeCompletionService/API/OpenAIService.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ extension OpenAIService {
267267
contextWindow - maxToken - 20
268268
))
269269
let prompts = strategy.createTruncatedPrompt(promptStrategy: request)
270+
// if request.systemPrompt empty not append
271+
if request.systemPrompt.isEmpty {
272+
return prompts.map(\.content).joined(separator: "\n\n")
273+
}
270274
return ([request.systemPrompt] + prompts.map(\.content)).joined(separator: "\n\n")
271275
}
272276

Core/Sources/Storage/Preferences.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ public extension UserDefaultPreferenceKeys {
129129
)
130130
}
131131

132+
var fimAttachFileInfo: PreferenceKey<Bool> {
133+
.init(
134+
defaultValue: true,
135+
key: "CustomSuggestionService-fimAttachFileInfo"
136+
)
137+
}
138+
132139
var maxGenerationToken: PreferenceKey<Int> {
133140
.init(
134141
defaultValue: 200,

Core/Sources/SuggestionService/RequestStrategies/FillInTheMiddleRequestStrategy.swift

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ struct FillInTheMiddleRequestStrategy: RequestStrategy {
4040
var suffix: [String]
4141
var filePath: String { sourceRequest.relativePath ?? sourceRequest.fileURL.path }
4242
var relevantCodeSnippets: [RelevantCodeSnippet] { sourceRequest.relevantCodeSnippets }
43-
var stopWords: [String] { ["\n\n", Tag.stop].filter { !$0.isEmpty } }
43+
// Stop words should support multiple comma-separated
44+
var stopWords: [String] {
45+
return ["\n\n"] + Tag.stop.split(separator: ",").map { String($0) }.filter { !$0.isEmpty }
46+
}
4447
var language: CodeLanguage? { sourceRequest.language }
4548
var promptIsRaw: Bool { UserDefaults.shared.value(for: \.fimPromptIsRaw) }
49+
var attachFileInfo: Bool { UserDefaults.shared.value(for: \.fimAttachFileInfo) }
4650

4751
var suggestionPrefix: SuggestionPrefix {
4852
guard let prefix = prefix.last else { return .empty }
@@ -57,15 +61,17 @@ struct FillInTheMiddleRequestStrategy: RequestStrategy {
5761
let suffix = truncatedSuffix.joined()
5862
var template = UserDefaults.shared.value(for: \.fimTemplate)
5963
if template.isEmpty { template = UserDefaults.shared.defaultValue(for: \.fimTemplate) }
60-
64+
// Determine whether to append file information according to attachFileInfo
65+
let fileInfo = attachFileInfo ? """
66+
// File Path: \(filePath)
67+
// Indentation: \
68+
\(sourceRequest.indentSize) \
69+
\(sourceRequest.usesTabsForIndentation ? "tab" : "space")
70+
""" : ""
6171
let prefixContent = """
62-
// File Path: \(filePath)
63-
// Indentation: \
64-
\(sourceRequest.indentSize) \
65-
\(sourceRequest.usesTabsForIndentation ? "tab" : "space")
66-
\(includedSnippets.map(\.content).joined(separator: "\n\n"))
67-
\(truncatedPrefix.joined())
68-
"""
72+
\(fileInfo)\(fileInfo.isEmpty ? "" : "\n")\(includedSnippets.map(\.content).joined(separator: "\n\n"))
73+
\(truncatedPrefix.joined())
74+
"""
6975

7076
let suffixContent = suffix.isEmpty ? "\n// End of file" : suffix
7177

CustomSuggestionService.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@
719719
repositoryURL = "https://github.com/sparkle-project/Sparkle";
720720
requirement = {
721721
kind = upToNextMajorVersion;
722-
minimumVersion = 2.5.2;
722+
minimumVersion = 2.6.4;
723723
};
724724
};
725725
C8D0116D2B5A5BFF00219412 /* XCRemoteSwiftPackageReference "CopilotForXcodeKit" */ = {

CustomSuggestionService.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CustomSuggestionService/ContentView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ struct RequestStrategyPicker: View {
183183
@AppStorage(\.fimTemplate) var fimTemplate
184184
@AppStorage(\.fimPromptIsRaw) var fimPromptIsRaw
185185
@AppStorage(\.fimStopToken) var fimStopToken
186+
@AppStorage(\.fimAttachFileInfo) var fimAttachFileInfo
186187
}
187188

188189
@StateObject var settings = Settings()
@@ -238,6 +239,7 @@ struct RequestStrategyPicker: View {
238239
prompt: Text(UserDefaults.shared.defaultValue(for: \.fimTemplate))
239240
) { Text("FIM Template") }
240241
Toggle(isOn: $settings.fimPromptIsRaw) { Text("Raw Prompt") }
242+
Toggle(isOn: $settings.fimAttachFileInfo) { Text("Attach File Info") }
241243
TextField(text: $settings.fimStopToken) { Text("FIM Stop Token") }
242244
}
243245
}

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ If you are new to running a model locally, you can try [Ollama](https://ollama.c
3434

3535
- Use Tabby since they have extensive experience in code completion.
3636
- Use models with completions API with Fill-in-the-Middle support (for example, codellama:7b-code), and use the "Fill-in-the-Middle" strategy.
37+
38+
You can find some [examples here](#example-use-of-local-models).
3739
- Use models with FIM API.
3840

3941
When using custom models to generate suggestions, it is recommended to setup a lower suggestion limit for faster generation.
@@ -61,6 +63,15 @@ The template format differs in different tools.
6163
- Naive: This strategy rearranges the code in a naive way to trick the model into believing it's appending code at the end of a file.
6264
- Continue: This strategy employs the "Please Continue" technique to persuade the model that it has started a suggestion and must continue to complete it. (Only effective with the chat completion API).
6365

66+
## Example Use of Local Models
67+
68+
### Qwen Type in the Middle
69+
70+
1. Load `qwen2.5-coder:32b` with Ollama.
71+
2. Setup the model with the completions API.
72+
3. Set the request strategy to "Fill-in-the-Middle".
73+
4. Set prompt format to `<|fim_prefix|>{prefix}<|fim_suffix|>{suffix}<|fim_middle|>` and turn on Raw Prompt.
74+
6475
## Contribution
6576

6677
Prompt engineering is a challenging task, and your assistance is invaluable.
@@ -69,4 +80,4 @@ The most complex things are located within the `Core` package.
6980

7081
- To add a new service, please refer to the `CodeCompletionService` folder.
7182
- To add new request strategies, check out the `SuggestionService` folder.
72-
83+
- To add a new instructions of using a local model, update the `Example Use of Local Models` in the README.md.

Version.xcconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
APP_VERSION = 0.6.0
2-
APP_BUILD = 60
1+
APP_VERSION = 0.7.0
2+
APP_BUILD = 74
33

appcast.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
<rss xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" version="2.0">
33
<channel>
44
<title>Custom Suggestion Service</title>
5+
<item>
6+
<title>0.7.0</title>
7+
<pubDate>Sat, 05 Apr 2025 16:06:39 +0800</pubDate>
8+
<sparkle:version>74</sparkle:version>
9+
<sparkle:shortVersionString>0.7.0</sparkle:shortVersionString>
10+
<sparkle:minimumSystemVersion>13.0</sparkle:minimumSystemVersion>
11+
<sparkle:releaseNotesLink>https://github.com/intitni/CustomSuggestionServiceForCopilotForXcode/releases/tag/0.7.0</sparkle:releaseNotesLink>
12+
<enclosure url="https://github.com/intitni/CustomSuggestionServiceForCopilotForXcode/releases/download/0.7.0/Custom.Suggestion.Service.app.zip" length="6790057" type="application/octet-stream" sparkle:edSignature="pMMViYEVPErbAbHixghC2lG6Q6XbuWkDccFOOpF9XOyd8vnj7zwXLc34Su6Pq55UtC1Y4Ryc8KcKy7QDfsqRDg=="/>
13+
</item>
514
<item>
615
<title>0.6.0</title>
716
<pubDate>Sun, 29 Dec 2024 23:59:31 +0800</pubDate>
@@ -20,14 +29,5 @@
2029
<sparkle:releaseNotesLink>https://github.com/intitni/CustomSuggestionServiceForCopilotForXcode/releases/tag/0.5.0</sparkle:releaseNotesLink>
2130
<enclosure url="https://github.com/intitni/CustomSuggestionServiceForCopilotForXcode/releases/download/0.5.0/Custom.Suggestion.Service.app.zip" length="6780334" type="application/octet-stream" sparkle:edSignature="xPs4zYq3gVWjR/VAGhT0RyAZsvmq605Cg+JpRM9CF8ap8ETqhJvj7q1VOcc8UdtllRX94+po9AF/92KoSMZ7Dw=="/>
2231
</item>
23-
<item>
24-
<title>0.4.0</title>
25-
<pubDate>Mon, 24 Jun 2024 00:33:39 +0800</pubDate>
26-
<sparkle:version>40</sparkle:version>
27-
<sparkle:shortVersionString>0.4.0</sparkle:shortVersionString>
28-
<sparkle:minimumSystemVersion>13.0</sparkle:minimumSystemVersion>
29-
<sparkle:releaseNotesLink>https://github.com/intitni/CustomSuggestionServiceForCopilotForXcode/releases/tag/0.4.0</sparkle:releaseNotesLink>
30-
<enclosure url="https://github.com/intitni/CustomSuggestionServiceForCopilotForXcode/releases/download/0.4.0/Custom.Suggestion.Service.app.zip" length="6989834" type="application/octet-stream" sparkle:edSignature="XHzYNwl8xKgmSYNh3hd2Z1BymuCvFWxSAAYBqclsuChH3iPJswPa8hbYzj07sqaaNc0LTODtv6cifZCOVMgPAg=="/>
31-
</item>
3232
</channel>
3333
</rss>

0 commit comments

Comments
 (0)