Skip to content

Commit

Permalink
Merge pull request #141 from allenai/develop
Browse files Browse the repository at this point in the history
Develop to Prod
  • Loading branch information
Stanley-Jovel authored Feb 1, 2025
2 parents dc07d50 + ddff302 commit 2c8ecd0
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 2 deletions.
17 changes: 17 additions & 0 deletions OLMoE.swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
48952DF02D4D69D400476373 /* MarkdownUI in Frameworks */ = {isa = PBXBuildFile; productRef = 48952DEF2D4D69D400476373 /* MarkdownUI */; };
489710A22D14D22600F0DB43 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 489710A12D14D22600F0DB43 /* README.md */; };
489FD75C2CF13E4E0011E908 /* AttestManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 489FD75B2CF13E4E0011E908 /* AttestManager.swift */; };
48B806352CF54D9F00E1CC0A /* LambdaResponseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48B806342CF54D9600E1CC0A /* LambdaResponseModel.swift */; };
Expand Down Expand Up @@ -68,6 +69,7 @@
buildActionMask = 2147483647;
files = (
A0117FFF2C990F5600035007 /* llama in Frameworks */,
48952DF02D4D69D400476373 /* MarkdownUI in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -167,6 +169,7 @@
name = OLMoE.swift;
packageProductDependencies = (
A0117FFE2C990F5600035007 /* llama */,
48952DEF2D4D69D400476373 /* MarkdownUI */,
);
productName = OLMoE.swift;
productReference = A0117FE82C990EAB00035007 /* OLMoE.swift.app */;
Expand Down Expand Up @@ -201,6 +204,7 @@
mainGroup = A0117FDF2C990EAB00035007;
packageReferences = (
A0117FFD2C990F5600035007 /* XCRemoteSwiftPackageReference "llama" */,
48952DEE2D4D69D400476373 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */,
);
productRefGroup = A0117FE92C990EAB00035007 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -484,6 +488,14 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
48952DEE2D4D69D400476373 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/gonzalezreal/swift-markdown-ui";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.4.1;
};
};
A0117FFD2C990F5600035007 /* XCRemoteSwiftPackageReference "llama" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/ggerganov/llama.cpp/";
Expand All @@ -495,6 +507,11 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
48952DEF2D4D69D400476373 /* MarkdownUI */ = {
isa = XCSwiftPackageProductDependency;
package = 48952DEE2D4D69D400476373 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */;
productName = MarkdownUI;
};
A0117FFE2C990F5600035007 /* llama */ = {
isa = XCSwiftPackageProductDependency;
package = A0117FFD2C990F5600035007 /* XCRemoteSwiftPackageReference "llama" */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "402af258bf43472ab0327a550b97a823103f59f5d378a15df589abdcebd30692",
"originHash" : "9fc5d8266c0b4820e5e9a3d82025e85b35f5476d810ce5eabdc737887aeadcdd",
"pins" : [
{
"identity" : "llama.cpp",
Expand All @@ -8,6 +8,33 @@
"state" : {
"revision" : "cc98896db858df7aa40d0e16a505883ef196a482"
}
},
{
"identity" : "networkimage",
"kind" : "remoteSourceControl",
"location" : "https://github.com/gonzalezreal/NetworkImage",
"state" : {
"revision" : "2849f5323265386e200484b0d0f896e73c3411b9",
"version" : "6.0.1"
}
},
{
"identity" : "swift-cmark",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-cmark",
"state" : {
"revision" : "3ccff77b2dc5b96b77db3da0d68d28068593fa53",
"version" : "0.5.0"
}
},
{
"identity" : "swift-markdown-ui",
"kind" : "remoteSourceControl",
"location" : "https://github.com/gonzalezreal/swift-markdown-ui",
"state" : {
"revision" : "5f613358148239d0292c0cef674a3c2314737f9e",
"version" : "2.4.1"
}
}
],
"version" : 3
Expand Down
120 changes: 119 additions & 1 deletion OLMoE.swift/Views/ChatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


import SwiftUI
import MarkdownUI

public struct UserChatBubble: View {
var text: String
Expand Down Expand Up @@ -43,11 +44,28 @@ public struct BotChatBubble: View {
if isGenerating && text.isEmpty {
TypingIndicator()
} else {
Text(text)
Markdown(text)
.padding(.top, -2)
.background(Color("BackgroundColor"))
.frame(maxWidth: maxWidth * 0.75, alignment: .leading)
.font(.body())
.markdownTextStyle(\.code) {
FontFamilyVariant(.monospaced)
FontSize(.em(0.85))
BackgroundColor(Color("Surface").opacity(0.35))
}
.markdownBlockStyle(\.codeBlock) { configuration in
configuration.label
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.horizontal, 12)
.padding(.vertical, 6)
.background(Color("Surface").opacity(0.35))
.markdownTextStyle {
FontFamilyVariant(.monospaced)
FontSize(.em(0.85))
}
.markdownMargin(top: 8, bottom: 8)
}
}
Spacer()
}
Expand Down Expand Up @@ -296,6 +314,106 @@ public struct ChatView: View {
}
}

#Preview("Markdown Features") {
let exampleHistory: [Chat] = [
Chat(role: .user, content: "Show me what markdown features you support"),
Chat(role: .bot, content: """
# Markdown Showcase
Let me demonstrate the various markdown features I support:
## Text Formatting
You can use **bold**, *italic*, or ***both***. You can also ~~strikethrough~~ text.
## Code Examples
Here's a code sample:
```swift
struct Example {
let value: String
func process() -> String {
return "Processed: \\(value)"
}
}
```
You can also use `inline code` or ``nested `backticks` ``.
## Lists and Tasks
Here's what I can do:
1. Ordered lists
* Nested bullets
* Deep nesting
And task lists:
- [x] Completed task
- [ ] Pending task
- [x] Nested task
"""),

Chat(role: .user, content: "That's cool! What about tables and quotes?"),
Chat(role: .bot, content: """
## Tables
| Feature | Support | Notes |
|---------|:-------:|-------|
| Tables | ✅ | With alignment |
| Lists | ✅ | Nested too |
## Blockquotes
> Single quote
>> Nested quote
>>> Triple nested with **bold** and *italic*
## Links and References
[External Link](https://example.com)
<https://auto-link.com>
Reference-style [link][ref] and footnotes[^1]
[^1]: This is a footnote
[ref]: https://example.com
"""),

Chat(role: .user, content: "Any special features?"),
Chat(role: .bot, content: """
## Special Elements
<details>
<summary>Expandable Section</summary>
* Hidden content
* More items
</details>
## Math and Diagrams
Math: $E = mc^2$
```mermaid
graph TD;
A-->B;
B-->C;
C-->D;
```
## Definition Lists
Term 1
: First definition
: Another definition
Term 2
: With nested list
* Item 1
* Item 2
""")
]

ChatView(
history: exampleHistory,
output: "",
isGenerating: .constant(false),
isScrolledToBottom: .constant(true),
stopSubmitted: .constant(false)
)
.padding(12)
.background(Color("BackgroundColor"))
}

#Preview("Replying") {
let exampleOutput = "This is a bot response that spans multiple lines to better test spacing and alignment in the chat view during development previews in Xcode. This is a bot response that spans multiple lines to better test spacing and alignment in the chat view during development previews in Xcode."
let exampleHistory: [Chat] = [
Expand Down

0 comments on commit 2c8ecd0

Please sign in to comment.