Build AI Studio 1.1 for macOS #1
@@ -426,6 +426,7 @@ enum KnowledgeInventory {
|
|||||||
static let toolName = "list_knowledge_sources"
|
static let toolName = "list_knowledge_sources"
|
||||||
|
|
||||||
static func matches(_ prompt: String) -> Bool {
|
static func matches(_ prompt: String) -> Bool {
|
||||||
|
if asksWhatIsInside(prompt) { return true }
|
||||||
let words = Set(prompt.lowercased().split { !$0.isLetter })
|
let words = Set(prompt.lowercased().split { !$0.isLetter })
|
||||||
let inventory = !words.isDisjoint(with: ["list", "show", "browse", "what", "which", "summarize", "categorize"])
|
let inventory = !words.isDisjoint(with: ["list", "show", "browse", "what", "which", "summarize", "categorize"])
|
||||||
let subjects = !words.isDisjoint(with: ["topics", "documents", "files", "sources", "contents", "indexed", "categories", "overview", "summaries"])
|
let subjects = !words.isDisjoint(with: ["topics", "documents", "files", "sources", "contents", "indexed", "categories", "overview", "summaries"])
|
||||||
@@ -433,10 +434,17 @@ enum KnowledgeInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static func wantsTopics(_ prompt: String) -> Bool {
|
static func wantsTopics(_ prompt: String) -> Bool {
|
||||||
|
if asksWhatIsInside(prompt) { return true }
|
||||||
let words = Set(prompt.lowercased().split { !$0.isLetter })
|
let words = Set(prompt.lowercased().split { !$0.isLetter })
|
||||||
return !words.isDisjoint(with: ["topics", "categories", "overview", "summaries"])
|
return !words.isDisjoint(with: ["topics", "categories", "overview", "summaries"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static func asksWhatIsInside(_ prompt: String) -> Bool {
|
||||||
|
let normalized = prompt.lowercased().split { !$0.isLetter }.joined(separator: " ")
|
||||||
|
return normalized.range(of: #"^(?:what is|what s) (?:in|inside) (?:(?:our|my|the) )?knowledge base$"#,
|
||||||
|
options: .regularExpression) != nil
|
||||||
|
}
|
||||||
|
|
||||||
static func topicOverview(_ sources: [String]) -> String {
|
static func topicOverview(_ sources: [String]) -> String {
|
||||||
let categories: [(String, String, Set<String>)] = [
|
let categories: [(String, String, Set<String>)] = [
|
||||||
("Development standards", "Standards, guidelines, conventions, and policies.", ["standards", "guidelines", "conventions", "policies"]),
|
("Development standards", "Standards, guidelines, conventions, and policies.", ["standards", "guidelines", "conventions", "policies"]),
|
||||||
|
|||||||
@@ -962,7 +962,7 @@ final class ConnectedChatTests: XCTestCase {
|
|||||||
let listed = reply.content.split(separator: "\n").filter { $0.hasPrefix("• ") }
|
let listed = reply.content.split(separator: "\n").filter { $0.hasPrefix("• ") }
|
||||||
XCTAssertGreaterThan(listed.count, 200)
|
XCTAssertGreaterThan(listed.count, 200)
|
||||||
XCTAssertEqual(Set(listed).count, listed.count)
|
XCTAssertEqual(Set(listed).count, listed.count)
|
||||||
studio.prompt = "List all topics in our knowledge base"
|
studio.prompt = "What is in our knowledge base?"
|
||||||
studio.send(endpoint: "", model: "", mlxPath: "", thinking: .off, failover: false,
|
studio.send(endpoint: "", model: "", mlxPath: "", thinking: .off, failover: false,
|
||||||
mlxOnly: false, compatible: false, recall: false, useDocuments: false,
|
mlxOnly: false, compatible: false, recall: false, useDocuments: false,
|
||||||
instructions: "", settings: GenerationSettings())
|
instructions: "", settings: GenerationSettings())
|
||||||
|
|||||||
Reference in New Issue
Block a user