-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
115 additions
and
48 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
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,27 @@ | ||
// | ||
// SynthesisEntryViewModel.swift | ||
// wallabag | ||
// | ||
// Created by maxime marinel on 22/01/2024. | ||
// | ||
|
||
import Factory | ||
import Foundation | ||
|
||
final class SynthesisEntryViewModel: ObservableObject { | ||
@Injected(\.chatAssistant) private var chatAssistant | ||
@Published var synthesis = "" | ||
@Published var isLoading = false | ||
|
||
@MainActor | ||
func generateSynthesis(from entry: Entry) async throws { | ||
defer { | ||
isLoading = false | ||
} | ||
isLoading = true | ||
|
||
guard let content = entry.content?.withoutHTML else { return } | ||
|
||
synthesis = try await chatAssistant.generateSynthesis(content: content) | ||
} | ||
} |
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,41 @@ | ||
// | ||
// TagSuggestionViewModel.swift | ||
// wallabag | ||
// | ||
// Created by maxime marinel on 22/01/2024. | ||
// | ||
|
||
import Factory | ||
import Foundation | ||
|
||
final class TagSuggestionViewModel: ObservableObject { | ||
@Injected(\.wallabagSession) private var wallabagSession | ||
@Injected(\.chatAssistant) private var chatAssistant | ||
@Published var suggestions: [String] = [] | ||
@Published var isLoading = false | ||
@Published var addingTags = false | ||
@Published var tagSelections = Set<String>() | ||
|
||
@MainActor | ||
func generateTags(from entry: Entry) async throws { | ||
defer { | ||
isLoading = false | ||
} | ||
isLoading = true | ||
|
||
guard let content = entry.content?.withoutHTML else { return } | ||
|
||
suggestions = try await chatAssistant.generateTags(content: content) | ||
} | ||
|
||
@MainActor | ||
func addTags(to entry: Entry) async throws { | ||
defer { | ||
addingTags = false | ||
} | ||
addingTags = true | ||
for tag in tagSelections { | ||
wallabagSession.add(tag: tag, for: entry) | ||
} | ||
} | ||
} |
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