-
Notifications
You must be signed in to change notification settings - Fork 352
Ios demo polish #454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Ios demo polish #454
Changes from 6 commits
fe562c8
bb77403
13dc851
4a6150f
e2ab620
8aab1fa
c9c6ca6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,7 +24,8 @@ extension LLMViewModel { | |||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| for try await token in stream { | ||||||||||||||||||||||||||||||||||||||||||||||||
| fullResponse += token | ||||||||||||||||||||||||||||||||||||||||||||||||
| await updateMessageContent(at: messageIndex, content: fullResponse) | ||||||||||||||||||||||||||||||||||||||||||||||||
| let displayText = Self.stripThinkTags(from: fullResponse) | ||||||||||||||||||||||||||||||||||||||||||||||||
| await updateMessageContent(at: messageIndex, content: displayText) | ||||||||||||||||||||||||||||||||||||||||||||||||
| NotificationCenter.default.post( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
25
to
29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skip no-op UI updates while the model is still inside
Suggested simplification func generateStreamingResponse(
prompt: String,
options: LLMGenerationOptions,
messageIndex: Int
) async throws {
var fullResponse = ""
+ var lastDisplayText = ""
let streamingResult = try await RunAnywhere.generateStream(prompt, options: options)
let stream = streamingResult.stream
let metricsTask = streamingResult.result
for try await token in stream {
fullResponse += token
let displayText = Self.stripThinkTags(from: fullResponse)
+ guard displayText != lastDisplayText else { continue }
+ lastDisplayText = displayText
await updateMessageContent(at: messageIndex, content: displayText)
NotificationCenter.default.post(
name: Notification.Name("MessageContentUpdated"),
object: nil
)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||
| name: Notification.Name("MessageContentUpdated"), | ||||||||||||||||||||||||||||||||||||||||||||||||
| object: nil | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,8 @@ struct ChatInterfaceView: View { | |
| @State private var showingLoRAManagement = false | ||
| @State private var pendingLoRAURL: URL? | ||
| @State private var loraScale: Float = 1.0 | ||
| @ObservedObject private var toolSettingsViewModel = ToolSettingsViewModel.shared | ||
| @AppStorage("thinkingModeEnabled") private var thinkingModeEnabled = false | ||
|
Comment on lines
+34
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid a second source of truth for thinking mode.
Suggested direction- `@ObservedObject` private var toolSettingsViewModel = ToolSettingsViewModel.shared
- `@AppStorage`("thinkingModeEnabled") private var thinkingModeEnabled = false
+ `@ObservedObject` private var toolSettingsViewModel = ToolSettingsViewModel.shared
+ `@ObservedObject` private var settingsViewModel = SettingsViewModel.shared
...
- if thinkingModeEnabled && viewModel.loadedModelSupportsThinking {
+ if settingsViewModel.thinkingModeEnabled && viewModel.loadedModelSupportsThinking {
thinkingModeBadge
}
...
- .padding(.top, ((thinkingModeEnabled && viewModel.loadedModelSupportsThinking) || viewModel.useToolCalling || !viewModel.loraAdapters.isEmpty || hasModelSelected) ? 8 : 0)
+ .padding(.top, ((settingsViewModel.thinkingModeEnabled && viewModel.loadedModelSupportsThinking) || viewModel.useToolCalling || !viewModel.loraAdapters.isEmpty || hasModelSelected) ? 8 : 0)
...
var thinkingModeBadge: some View {
Button {
- thinkingModeEnabled.toggle()
+ settingsViewModel.thinkingModeEnabled.toggle()
} label: {Also applies to: 502-518 🤖 Prompt for AI Agents |
||
| @FocusState private var isTextFieldFocused: Bool | ||
|
|
||
| private let logger = Logger( | ||
|
|
@@ -369,8 +371,8 @@ extension ChatInterfaceView { | |
| .onReceive( | ||
| NotificationCenter.default.publisher(for: Notification.Name("MessageContentUpdated")) | ||
| ) { _ in | ||
| if viewModel.isGenerating { | ||
| proxy.scrollTo("typing", anchor: .bottom) | ||
| if viewModel.isGenerating, let lastMessage = viewModel.messages.last { | ||
| proxy.scrollTo(lastMessage.id, anchor: .bottom) | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -412,7 +414,7 @@ extension ChatInterfaceView { | |
| .animation(nil, value: message.content) | ||
| } | ||
|
|
||
| if viewModel.isGenerating { | ||
| if viewModel.isGenerating, viewModel.messages.last?.content.isEmpty == true { | ||
| TypingIndicatorView() | ||
| .id("typing") | ||
| .transition(typingTransition) | ||
|
|
@@ -445,9 +447,13 @@ extension ChatInterfaceView { | |
| VStack(spacing: 0) { | ||
| Divider() | ||
|
|
||
| // Status badges (tool calling + LoRA) | ||
| // Status badges (thinking mode + tool calling + LoRA) | ||
| HStack(spacing: 8) { | ||
| if viewModel.useToolCalling { | ||
| if thinkingModeEnabled && viewModel.loadedModelSupportsThinking { | ||
| thinkingModeBadge | ||
| } | ||
|
|
||
| if viewModel.useToolCalling && !toolSettingsViewModel.registeredTools.isEmpty { | ||
| toolCallingBadge | ||
| } | ||
|
|
||
|
|
@@ -459,7 +465,7 @@ extension ChatInterfaceView { | |
| loraAddButton | ||
| } | ||
| } | ||
| .padding(.top, (viewModel.useToolCalling || !viewModel.loraAdapters.isEmpty || hasModelSelected) ? 8 : 0) | ||
| .padding(.top, ((thinkingModeEnabled && viewModel.loadedModelSupportsThinking) || viewModel.useToolCalling || !viewModel.loraAdapters.isEmpty || hasModelSelected) ? 8 : 0) | ||
|
|
||
| HStack(spacing: AppSpacing.mediumLarge) { | ||
| TextField("Type a message...", text: $viewModel.currentInput, axis: .vertical) | ||
|
|
@@ -493,6 +499,24 @@ extension ChatInterfaceView { | |
| } | ||
| } | ||
|
|
||
| var thinkingModeBadge: some View { | ||
| Button { | ||
| thinkingModeEnabled.toggle() | ||
| } label: { | ||
| HStack(spacing: 6) { | ||
| Image(systemName: "lightbulb.min.fill") | ||
| .font(.system(size: 10)) | ||
| Text("Thinking") | ||
| .font(AppTypography.caption2) | ||
| } | ||
| .foregroundColor(AppColors.primaryPurple) | ||
| .padding(.horizontal, 10) | ||
| .padding(.vertical, 4) | ||
| .background(AppColors.primaryPurple.opacity(0.1)) | ||
| .cornerRadius(6) | ||
| } | ||
| } | ||
|
|
||
| var toolCallingBadge: some View { | ||
| HStack(spacing: 6) { | ||
| Image(systemName: "wrench.and.screwdriver") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: RunanywhereAI/runanywhere-sdks
Length of output: 94
🏁 Script executed:
Repository: RunanywhereAI/runanywhere-sdks
Length of output: 805
🏁 Script executed:
Repository: RunanywhereAI/runanywhere-sdks
Length of output: 104
Update
fileSizeto match actual HuggingFace file size.The
fileSize: 0should be updated to17_620_224(the actual size in bytes). A zero file size can cause indeterminate progress indicators during download and inaccurate storage requirement estimates shown to users.Proposed fix
LoraAdapterCatalogEntry( id: "abliterated-lora", name: "Abliterated (Uncensored)", description: "Removes content restrictions for unrestricted responses", downloadURL: URL(string: "https://huggingface.co/Void2377/qwen-lora-gguf/resolve/main/qwen2.5-0.5b-abliterated-lora-f16.gguf")!, filename: "qwen2.5-0.5b-abliterated-lora-f16.gguf", compatibleModelIds: ["qwen2.5-0.5b-base-q8_0"], - fileSize: 0, + fileSize: 17_620_224, defaultScale: 1.0 ),📝 Committable suggestion
🤖 Prompt for AI Agents