-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Polishing and Summary Features (#609)
* perf: add icons for polishing and grammar * fix: wrong icon placement * perf: setup base for grammar and polishing * fix: missing files * fix: wrong service name for summary * perf: add LLMDerivService as the base of LLMDerivs * feat: implement polishing and summary features * refactor: make AIToolService override method chatMessageDicts() * perf: rename LLM Derivatives to AI Tools * perf: remove unused code * perf: improve prompts for text summary * fix: extraneous prompt * fix: use first preferred langauge to summarize text * feat: set AI tool service usage status to alway off by default * fix: add missing en localization * fix: icon size for polishing and grammar service * fix: format fewShots to conform to original prompt * perf(UI): add new icon for summary service --------- Co-authored-by: tisfeng <tisfeng@gmail.com>
- Loading branch information
1 parent
aaf6200
commit dafba90
Showing
16 changed files
with
314 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Easydict/App/Assets.xcassets/service-icon/Polishing.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Polishing.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "Polishing@2x.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+6.13 KB
Easydict/App/Assets.xcassets/service-icon/Polishing.imageset/Polishing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.1 KB
Easydict/App/Assets.xcassets/service-icon/Polishing.imageset/Polishing@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions
22
Easydict/App/Assets.xcassets/service-icon/Summary.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Summary.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "Summary@2x.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+5.44 KB
Easydict/App/Assets.xcassets/service-icon/Summary.imageset/Summary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.4 KB
Easydict/App/Assets.xcassets/service-icon/Summary.imageset/Summary@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// AIToolService.swift | ||
// Easydict | ||
// | ||
// Created by Jerry on 2024-07-12. | ||
// Copyright © 2024 izual. All rights reserved. | ||
// | ||
|
||
import Defaults | ||
import Foundation | ||
|
||
/// A class used for AI Tools such as summary and polishing | ||
class AIToolService: BuiltInAIService { | ||
// MARK: Public | ||
|
||
public override func configurationListItems() -> Any { | ||
StreamConfigurationView( | ||
service: self, | ||
showNameSection: false, | ||
showAPIKeySection: false, | ||
showEndpointSection: false, | ||
showSupportedModelsSection: false, | ||
showUsedModelSection: false, | ||
showTranslationToggle: false, | ||
showSentenceToggle: false, | ||
showDictionaryToggle: false, | ||
showUsageStatusPicker: true | ||
) | ||
} | ||
|
||
// MARK: Internal | ||
|
||
override var serviceUsageStatusKey: Defaults.Key<ServiceUsageStatus> { | ||
serviceDefaultsKey(.serviceUsageStatus, defaultValue: .alwaysOff) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// PolishingService.swift | ||
// Easydict | ||
// | ||
// Created by Jerry on 2024-07-11. | ||
// Copyright © 2024 izual. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import OpenAI | ||
|
||
@objc(EZPolishingService) | ||
class PolishingService: AIToolService { | ||
// MARK: Public | ||
|
||
public override func name() -> String { | ||
NSLocalizedString("polishing_service", comment: "") | ||
} | ||
|
||
public override func serviceType() -> ServiceType { | ||
.polishing | ||
} | ||
|
||
// MARK: Internal | ||
|
||
override func chatMessageDicts(_ chatQuery: ChatQueryParam) -> [[String: String]] { | ||
polishingMessages(chatQuery) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// SummaryService.swift | ||
// Easydict | ||
// | ||
// Created by Jerry on 2024-07-11. | ||
// Copyright © 2024 izual. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import OpenAI | ||
|
||
@objc(EZSummaryService) | ||
class SummaryService: AIToolService { | ||
// MARK: Public | ||
|
||
public override func name() -> String { | ||
NSLocalizedString("summary_service", comment: "") | ||
} | ||
|
||
public override func serviceType() -> ServiceType { | ||
.summary | ||
} | ||
|
||
// MARK: Internal | ||
|
||
override func chatMessageDicts(_ chatQuery: ChatQueryParam) -> [[String: String]] { | ||
summaryMessages(chatQuery) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.