Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ class AccessibilityNotificationsManager: ObservableObject {
AccessibilityParsedElements.applicationName: appName,
AccessibilityParsedElements.applicationTitle: appTitle,
AccessibilityParsedElements.elapsedTime: "\(CFAbsoluteTimeGetCurrent() - startTime)",
AccessibilityParsedElements.documentUrl: "Google drive document's url: " + url.absoluteString,
"document": documentContent
]
handleWindowContent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ struct AccessibilityParsedElements {
static let applicationTitle = "applicationTitle"
static let elapsedTime = "elapsedTime"

static let documentContent = "Document's content"
static let documentUrl = "Document's URL"

static let highlightedText = "highlightedText"
static let screen = "screen"
static let screen = "Plain text content"

struct Xcode {
static let editor = "editor"
Expand Down
20 changes: 20 additions & 0 deletions macos/Onit/Assets.xcassets/Colors/AcceptBG.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x38",
"green" : "0x68",
"red" : "0x2D"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.573",
"green" : "1.000",
"red" : "0.475"
"blue" : "0x92",
"green" : "0xFF",
"red" : "0x79"
}
},
"idiom" : "universal"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x61",
"green" : "0x5A",
"red" : "0xFF"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
20 changes: 20 additions & 0 deletions macos/Onit/Assets.xcassets/Colors/RejectBG.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x2B",
"green" : "0x27",
"red" : "0x8E"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.150",
"blue" : "0x00",
"green" : "0xFF",
"red" : "0x62"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
20 changes: 20 additions & 0 deletions macos/Onit/Assets.xcassets/Colors/diffBgRed.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.180",
"blue" : "0x00",
"green" : "0x00",
"red" : "0xFF"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
20 changes: 20 additions & 0 deletions macos/Onit/Assets.xcassets/Colors/diffRed.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x25",
"green" : "0x25",
"red" : "0xFF"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "lucide_diff.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Binary file not shown.
15 changes: 15 additions & 0 deletions macos/Onit/Assets.xcassets/Icons/notes.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Icon.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
3 changes: 3 additions & 0 deletions macos/Onit/Assets.xcassets/Icons/notes.imageset/Icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 39 additions & 33 deletions macos/Onit/Data/Fetching/ChatEndpointMessagesBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,57 @@ struct ChatEndpointMessagesBuilder {
static func user(instructions: [String], inputs: [Input?], files: [[URL]], autoContexts: [[String: String]], webSearchContexts: [[(title: String, content: String, source: String, url: URL?)]]) -> [String] {
var userMessages: [String] = []
for (index, instruction) in instructions.enumerated() {
var message = ""


// TODO: add error handling for contexts too long & incorrect file types
if !files[index].isEmpty {
message += "\n\nUse the following files as context:"
for file in files[index] {
if let fileContent = try? String(contentsOf: file, encoding: .utf8) {
message += "\n\nFile: \(file.lastPathComponent)\nContent:\n\(fileContent)"
}
}
}

var message = """
You are provided with multiple context sources below. Use them to fulfill the final instruction.
**Important rules:**
- If there is "Selected Text", prioritize it over all other content.
- Use only relevant information to fulfill the task;

"""

// 1. Application Contexts
if !autoContexts[index].isEmpty {
message += "\n\nUse the following application content as context:"
message += "\n---\n**Application Context**\n"
for (appName, appContent) in autoContexts[index] {
message += "\n\nContent from application \(appName):\n\(appContent)"
message += "\n[App: \(appName)]\n\(appContent)"
}
}

// Add web contexts
if index < webSearchContexts.count && !webSearchContexts[index].isEmpty {
message += "\n\nUse the following web search results as context:"
for webSearchContext in webSearchContexts[index] {
message += "\n\nWeb Search Result: \(webSearchContext.title)"
if !webSearchContext.source.isEmpty {
message += " (Source: \(webSearchContext.source))"

// 2. Web Search Results
if index < webSearchContexts.count, !webSearchContexts[index].isEmpty {
message += "\n---\n**Web Search Results**\n"
for web in webSearchContexts[index] {
message += "\n- Title: \(web.title)"
if !web.source.isEmpty {
message += " (Source: \(web.source))"
}
message += "\n\(web.content)"
}
}

// 3. Files
if !files[index].isEmpty {
message += "\n---\n**Attached Files**\n"
for file in files[index] {
if let content = try? String(contentsOf: file, encoding: .utf8) {
message += "\n[File: \(file.lastPathComponent)]\n\(content)"
}
message += "\n\(webSearchContext.content)"
}
}

if let input = inputs[index], !input.selectedText.isEmpty {
message += "\n\nUse the following selected text as context. When present, selected text should take priority over other context."
if let application = input.application {
message += "\n\nSelected Text from \(application): \(input.selectedText)"
// 4. Selected Text
if let input = inputs[index], !input.selectedText.isEmpty {
message += "\n---\n**Selected Text** (Highest Priority)\n"
if let app = input.application {
message += "From application \(app):\n\(input.selectedText)"
} else {
message += "\n\nSelected Text: \(input.selectedText)"
message += input.selectedText
}
}


// Intuitively, I (tim) think the message should be the last thing.
// TODO: evaluate this
message += "\n\n\(instruction)"
// 5. Final Instruction
message += "\n---\n**Instruction**\n"
message += instruction
userMessages.append(message)
}

Expand Down
Loading