new features
This commit is contained in:
@@ -174,7 +174,8 @@ final class StudioModel: ObservableObject {
|
||||
}
|
||||
|
||||
func send(endpoint: String, model: String, mlxPath: String, thinking: Thinking, failover: Bool,
|
||||
mlxOnly: Bool, compatible: Bool, recall: Bool, useDocuments: Bool, instructions: String, settings: GenerationSettings, agents: [AgentRole] = [], agentTools: Bool = false) {
|
||||
mlxOnly: Bool, compatible: Bool, recall: Bool, useDocuments: Bool, instructions: String, settings: GenerationSettings, agents: [AgentRole] = [], agentTools: Bool = false,
|
||||
ragEnabled: Bool = true, lmStudioPlugins: [String] = []) {
|
||||
let text = prompt.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let tag = model.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
guard !running, !text.isEmpty else { return }
|
||||
@@ -200,6 +201,8 @@ final class StudioModel: ObservableObject {
|
||||
let (name, generate) = try inferenceRoute(
|
||||
endpoint: endpoint, model: tag, mlxPath: mlxPath, mlxOnly: mlxOnly,
|
||||
compatible: compatible, failover: failover)
|
||||
let pluginClient = compatible && !mlxOnly && !lmStudioPlugins.isEmpty
|
||||
? try compatibleClient(endpoint: endpoint) : nil
|
||||
let parameters = try settings.parameters(mlxOnly: mlxOnly, compatible: compatible)
|
||||
let templates = Dictionary(uniqueKeysWithValues: snippets.filter { $0.kind == .prompt }.map {
|
||||
($0.id, PromptTemplate(body: $0.content, examples: $0.examples))
|
||||
@@ -260,7 +263,7 @@ final class StudioModel: ObservableObject {
|
||||
""")
|
||||
}
|
||||
}
|
||||
if !smallTalk && (useDocuments || activeStack != nil) && (agents.isEmpty || agents.contains(where: { $0.promptSettings.useDocuments })) {
|
||||
if ragEnabled && !smallTalk && (useDocuments || activeStack != nil) && (agents.isEmpty || agents.contains(where: { $0.promptSettings.useDocuments })) {
|
||||
let vector = DocumentVector.forPrompt(text)
|
||||
var excerpts = useDocuments ? try store.excerpts(matching: text, in: chat, vector: vector, includeLocations: true) : []
|
||||
if useDocuments && excerpts.isEmpty { excerpts = try store.openingExcerpts(in: chat, includeLocations: true) }
|
||||
@@ -283,9 +286,9 @@ final class StudioModel: ObservableObject {
|
||||
let webEnabled = UserDefaults.standard.object(forKey: "builtInWebEnabled") as? Bool != false
|
||||
let wantsRepositories = filePath == nil && GiteaRepositoryLookup.matches(text)
|
||||
let automaticWeb = UserDefaults.standard.object(forKey: "automaticChatWebSearch") as? Bool != false
|
||||
let remoteChoice = activeRemoteStack
|
||||
let remoteChoice = ragEnabled ? activeRemoteStack : .off
|
||||
let maySearchAutomatically = automaticWeb && (remoteChoice == .automatic || remoteChoice == .off) && !smallTalk && !wantsRepositories && attachment == nil &&
|
||||
!(useDocuments && !documents.isEmpty) && activeStack == nil && activeContext == nil && activeSkill == nil && activeWebClip == nil
|
||||
(!ragEnabled || (!(useDocuments && !documents.isEmpty) && activeStack == nil)) && activeContext == nil && activeSkill == nil && activeWebClip == nil
|
||||
let lookup = filePath == nil && webEnabled
|
||||
? ChatWebLookup.forChat(message: text, recent: Array(recent), automatic: maySearchAutomatically) : nil
|
||||
let explicitWeb = ChatWebLookup(message: text) != nil
|
||||
@@ -436,6 +439,11 @@ final class StudioModel: ObservableObject {
|
||||
let prepared = try StudioPromptRequest.prepare(
|
||||
messages, template: template, options: options, parameters: parameters)
|
||||
if final { self.partial?.documentCitations = prepared.citations }
|
||||
if final, let pluginClient {
|
||||
return pluginClient.generateWithPlugins(
|
||||
InferenceRequest(model: tag, messages: prepared.messages, thinking: requestThinking,
|
||||
parameters: prepared.parameters), plugins: lmStudioPlugins)
|
||||
}
|
||||
return generate(prepared.messages, final ? requestThinking : .off, prepared.parameters)
|
||||
} catch {
|
||||
return AsyncThrowingStream { $0.finish(throwing: error) }
|
||||
|
||||
Reference in New Issue
Block a user