Skip to content

Commit 7ed29e3

Browse files
Merge pull request #12 from QuickBlox/Release-0.1.7
0.1.7
2 parents 6ae794a + a21ed20 commit 7ed29e3

File tree

62 files changed

+1260
-1207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1260
-1207
lines changed

Package.resolved

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

Package.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ let package = Package(
1818
dependencies: [
1919
.package(url: "https://github.com/QuickBlox/ios-quickblox-sdk", .upToNextMajor(from: "2.19.0")),
2020
.package(url: "https://github.com/QuickBlox/ios-ai-answer-assistant.git", .upToNextMajor(from: "1.0.0")),
21-
.package(url: "https://github.com/QuickBlox/ios-ai-translate.git", .upToNextMajor(from: "1.0.0"))
21+
.package(url: "https://github.com/QuickBlox/ios-ai-translate.git", .upToNextMajor(from: "1.0.0")),
22+
.package(url: "https://github.com/QuickBlox/ios-ai-rephrase", .upToNextMajor(from: "1.0.0"))
2223
],
2324
targets: [
2425
.target(
@@ -38,7 +39,9 @@ let package = Package(
3839
.product(name: "QBAIAnswerAssistant",
3940
package: "ios-ai-answer-assistant"),
4041
.product(name: "QBAITranslate",
41-
package: "ios-ai-translate")]),
42+
package: "ios-ai-translate"),
43+
.product(name: "QBAIRephrase",
44+
package: "ios-ai-rephrase")]),
4245
.target(
4346
name: "QuickBloxLog",
4447
dependencies: []),

README.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ QuickBloxUIKit comes with a range of AI features that enhance the capabilities o
315315
| Feature | Group Dialog | Private Dialog |
316316
| :------------ | :----------- | :------------- |
317317
| Assist Answer |||
318+
| Translate |||
319+
| Rephrase |||
318320

319321
## Assist Answer
320322

@@ -491,3 +493,171 @@ Resources:
491493

492494
- [QBAIProxy Server](https://github.com/QuickBlox/qb-ai-assistant-proxy-server)
493495
- [QBAITranslate Swift Package](https://github.com/QuickBlox/QBAITranslate)
496+
497+
## Rephrase
498+
499+
The AI Rephrase feature in QuickBloxUIKit empowers you to seamlessly integrate AI Rephrase capabilities into your chat-based application using the [QBAIRephrase Swift package](https://github.com/QuickBlox/ios-ai-rephrase). This feature leverages the OpenAI [API key](https://platform.openai.com/account/api-keys) or [proxy server](https://github.com/QuickBlox/qb-ai-assistant-proxy-server) to generate responses more securely and efficiently.
500+
501+
[block:image]
502+
{
503+
"images": [
504+
{
505+
"image": [
506+
"https://files.readme.io/d40175f-IMG_1221.PNG",
507+
"",
508+
""
509+
],
510+
"align": "center",
511+
"sizing": "400px",
512+
"border": true
513+
}
514+
]
515+
}
516+
[/block]
517+
518+
The AI Rephrase library allows you to rephrase a message using different tones so that the user can communicate effectively in different situations.
519+
520+
### How to Use
521+
522+
To use the AI Rephrase feature in your QuickBloxUIKit project, follow these steps:
523+
524+
1. Enable the AI Rephrase feature:
525+
526+
```swift
527+
QuickBloxUIKit.feature.ai.rephrase.enable = true
528+
```
529+
530+
If this option is enabled, the user interface provides a clear option or menu that allows the user to select the desired tone.
531+
532+
[block:image]
533+
{
534+
"images": [
535+
{
536+
"image": [
537+
"https://files.readme.io/05dd773-IMG_1221.jpeg",
538+
"",
539+
""
540+
],
541+
"align": "center",
542+
"sizing": "400px",
543+
"border": true
544+
}
545+
]
546+
}
547+
[/block]
548+
549+
Once a tone is selected, the message is rephrased to reflect the characteristics of the selected tone.
550+
A paraphrased message retains the main purpose of the original message.
551+
552+
[block:image]
553+
{
554+
"images": [
555+
{
556+
"image": [
557+
"https://files.readme.io/14de923-IMG_1222.jpeg",
558+
"",
559+
""
560+
],
561+
"align": "center",
562+
"sizing": "400px",
563+
"border": true
564+
}
565+
]
566+
}
567+
[/block]
568+
569+
Users have the ability to seamlessly switch between different tones without having to rewrite the original message.
570+
571+
[block:image]
572+
{
573+
"images": [
574+
{
575+
"image": [
576+
"https://files.readme.io/a48525c-IMG_1223.jpeg",
577+
"",
578+
""
579+
],
580+
"align": "center",
581+
"sizing": "400px",
582+
"border": true
583+
}
584+
]
585+
}
586+
[/block]
587+
588+
After rephrasing a message, the user is given an easily accessible option to return to the original.
589+
Clicking on this "Back to original" option will instantly restore the message to its original state.
590+
591+
[block:image]
592+
{
593+
"images": [
594+
{
595+
"image": [
596+
"https://files.readme.io/c254562-IMG_1221.jpeg",
597+
"",
598+
""
599+
],
600+
"align": "center",
601+
"sizing": "400px",
602+
"border": true
603+
}
604+
]
605+
}
606+
[/block]
607+
608+
2. Set up the AI settings by providing either the OpenAI [API key](https://platform.openai.com/account/api-keys):
609+
610+
```swift
611+
QuickBloxUIKit.feature.ai.translate.openAIAPIKey = "YOUR_OPENAI_API_KEY"
612+
```
613+
614+
Or set up with a proxy server:
615+
616+
```swift
617+
QuickBloxUIKit.feature.ai.translate.proxyServerURLPath = "https://your-proxy-server-url"
618+
```
619+
620+
> 👍 We recommend using a proxy server like the [QuickBlox AI Assistant Proxy Server](https://github.com/QuickBlox/qb-ai-assistant-proxy-server) offers significant benefits in terms of security and functionality:
621+
>
622+
> - When making direct requests to the OpenAI API from the client-side, sensitive information like API keys may be exposed. By using a proxy server, the API keys are securely stored on the server-side, reducing the risk of unauthorized access or potential breaches.
623+
> - The proxy server can implement access control mechanisms, ensuring that only authenticated and authorized users with valid QuickBlox user tokens can access the OpenAI API. This adds an extra layer of security to the communication.
624+
625+
3. A developer using the AI Rephrase library has the ability to add custom ringtones to provide a more personalized experience for users. The developer will be able to define the name and behavior of a custom tone.
626+
627+
```swift Swift
628+
let customTone = QBAIRephrase.ToneInfo(name: "Custom Tone", behavior: "Custom behavior", icon: "🦊")
629+
QuickBloxUIKit.feature.ai.rephrase.append(tone: customTone)
630+
```
631+
632+
```
633+
Custom tone, if selected, rephrases messages according to the specified behavior.
634+
```
635+
636+
3. A developer using the AI Rephrase library has the ability to remove tones to tailor the user interface for their application.
637+
638+
```swift Swift
639+
QuickBloxUIKit.feature.ai.rephrase.remove(tone: QBAIRephrase.ToneInfo.sarcastic)
640+
```
641+
642+
Once removed, the default tone will no longer be available to end users.
643+
644+
Incorporate AI Rephrase into your iOS chat application seamlessly using the QBAIRephrase Swift package. Unlock the potential of AI-driven interactions and provide your users with real-time translation capabilities, enhancing user communication and experience.
645+
For additional resources, explore the QuickBlox AI Assistant Proxy Server and the QBAIRephrase Swift package repositories.
646+
Resources:
647+
648+
- [QBAIProxy Server](https://github.com/QuickBlox/qb-ai-assistant-proxy-server)
649+
- [QBAIRephrase Swift package](https://github.com/QuickBlox/QBAITranslate)
650+
- [QuickBlox Documentation](https://quickblox.com/documentation/ios/ai-features)
651+
652+
### Default tones:
653+
654+
- **Professional tone:** This will allow you to edit messages to sound more formal, using technical language, clear sentence structures, and maintaining a respectful tone. This would avoid colloquial language and ensure appropriate greetings and signatures.
655+
- **Friendly Tone:** This will allow you to tailor your messages to reflect a casual, friendly tone. It will include casual language, use emoticons, exclamation points and other informal elements to make the message seem more friendly and approachable.
656+
- **Encouraging tone**: This tone will be useful for motivation and encouragement. It will include positive words, affirmations and express support and faith in the recipient.
657+
- **Empathic Tone:** This tone will be used to show understanding and empathy. This will require softer language, acknowledgment of feelings, and demonstrations of compassion and support.
658+
- **Neutral Tone:** For when you want to maintain an even, impartial and objective tone. He will avoid harsh statements and emotional words, preferring clear and direct communication.
659+
- **Assertive Tone**: This tone is useful for making a clear statement, asserting a position, or in negotiations. He uses direct speech, is confident and does not soften his words.
660+
- **Instructive Tone:** This tone would be useful for tutorials, guides, or other teaching and learning materials. It is clear, concise and logically guides the reader through the steps or processes.
661+
- **Persuasive Tone:** This tone can be used when trying to convince someone or to argue your point. He uses persuasive language, strong words and logical reasoning.
662+
- **Sarcastic/Ironic Tone:** This tone can make the communication more humorous or convey an ironic attitude. It is more difficult to implement because it requires the AI to understand the nuances of the language and may not always be perceived by the reader as intended.
663+
- **Poetic Tone:** This will add an artistic touch to messages by using figurative language, rhyme, and rhythm to create more expressive text.

Sources/QuickBloxData/Repository/FilesRepository.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ private extension File {
8989
path: value.path,
9090
uid: value.uid)
9191
data = value.data
92+
info.type = value.type
9293
}
9394
}
9495

@@ -101,6 +102,7 @@ private extension File {
101102
path: value.path,
102103
uid: value.uid)
103104
data = value.data
105+
info.type = value.type
104106
}
105107
}
106108

Sources/QuickBloxData/Repository/MessagesRepository.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private extension RemoteMessageDTO {
6868
RemoteFileInfoDTO(
6969
id: file.id,
7070
name: file.name,
71-
type: file.ext.type.rawValue,
71+
type: file.ext.mimeType,
7272
path: file.path.remote,
7373
uid: file.uid
7474
))

Sources/QuickBloxData/Source/Local/LocalDataSource.swift

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,29 @@ extension LocalDataSource {
6565
throw DataSourceException.notFound()
6666
}
6767

68+
var isUpdated = false
69+
6870
var dialog = dialogs.value[index]
6971

7072
if dto.name.isEmpty == false {
71-
dialog.name = dto.name
73+
if dialog.name != dto.name {
74+
isUpdated = true
75+
dialog.name = dto.name
76+
}
7277
}
7378

7479
if dto.participantsIds.isEmpty == false {
75-
dialog.participantsIds = dto.participantsIds
80+
if dialog.participantsIds != dto.participantsIds {
81+
isUpdated = true
82+
dialog.participantsIds = dto.participantsIds
83+
}
7684
}
7785

7886
if dto.photo.isEmpty == false {
79-
dialog.photo = dto.photo
87+
if dialog.photo != dto.photo {
88+
isUpdated = true
89+
dialog.photo = dto.photo
90+
}
8091
}
8192

8293
dialog.updatedAt = dto.updatedAt
@@ -89,27 +100,47 @@ extension LocalDataSource {
89100

90101
if dto.messages.isEmpty == false {
91102
for new in dto.messages {
103+
isUpdated = true
92104
dialog.messages.insertElement(new, withSorting: .orderedAscending)
93105
}
94106
}
95107

96108
if dto.lastMessageId.isEmpty == false {
97-
dialog.lastMessageId = dto.lastMessageId
109+
if dialog.lastMessageId != dto.lastMessageId {
110+
isUpdated = true
111+
dialog.lastMessageId = dto.lastMessageId
112+
}
98113
}
99114

100115
if dto.lastMessageText.isEmpty == false {
101-
dialog.lastMessageText = dto.lastMessageText
116+
if dialog.lastMessageText != dto.lastMessageText {
117+
isUpdated = true
118+
dialog.lastMessageText = dto.lastMessageText
119+
}
102120
}
103121

104122
if dto.lastMessageDateSent != Date(timeIntervalSince1970: 0.0) {
105-
dialog.lastMessageDateSent = dto.lastMessageDateSent
123+
if dialog.lastMessageDateSent != dto.lastMessageDateSent {
124+
isUpdated = true
125+
dialog.lastMessageDateSent = dto.lastMessageDateSent
126+
}
106127
}
107128

108129
if dto.lastMessageUserId.isEmpty == false {
109-
dialog.lastMessageUserId = dto.lastMessageUserId
130+
if dialog.lastMessageUserId != dto.lastMessageUserId {
131+
isUpdated = true
132+
dialog.lastMessageUserId = dto.lastMessageUserId
133+
}
110134
}
111135

112-
dialogs.value[index] = dialog
136+
if isUpdated == true {
137+
var value = dialogs.value
138+
value.remove(at: index)
139+
value.insert(dialog, at: 0)
140+
dialogs.value = value
141+
} else {
142+
dialogs.value[index] = dialog
143+
}
113144
}
114145

115146
func getAllDialogs() async throws -> LocalDialogsDTO {

0 commit comments

Comments
 (0)