Skip to content

Commit

Permalink
"Add llmfarm_core.swift as a remote source control dependency with ve…
Browse files Browse the repository at this point in the history
…rsion 0.8.1."
  • Loading branch information
buhe committed Jan 23, 2024
1 parent b923ad9 commit 3095a06
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 28 deletions.
9 changes: 9 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@
"version" : "4.2.2"
}
},
{
"identity" : "llmfarm_core.swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/guinmoon/llmfarm_core.swift",
"state" : {
"revision" : "7226a84a69361c312c997453827c609e613585fd",
"version" : "0.8.1"
}
},
{
"identity" : "openai-kit",
"kind" : "remoteSourceControl",
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let package = Package(
.package(url: "https://github.com/juyan/swift-filestore", .upToNextMajor(from: "0.5.0")),
.package(url: "https://github.com/ZachNagengast/similarity-search-kit.git", from: "0.0.11"),
.package(url: "https://github.com/google/generative-ai-swift", .upToNextMajor(from: "0.4.4")),
.package(path: "/Users/guyanhua/code/github/LLMFarm/llmfarm_core.swift/")
.package(url: "https://github.com/guinmoon/llmfarm_core.swift", .upToNextMajor(from: "0.8.1")),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
Expand Down
28 changes: 1 addition & 27 deletions Sources/LangChain/llms/Local.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,13 @@
//

import Foundation
import llmfarm_core
import llmfarm_core_cpp

public class Local {

public init() {
}

public func _send(text: String, stops: [String] = []) async throws -> LLMResult {
print("Hello.")
var input_text = "State the meaning of life."
var modelInference:ModelInference
var ai = AI(_modelPath: "/Users/guyanhua/llama-2-7b-chat.Q3_K_S.gguf",_chatName: "chat")
modelInference = ModelInference.LLama_gguf
var params:ModelAndContextParams = .default
params.context = 4095
params.n_threads = 14
//
params.use_metal = false

do{
try ai.loadModel(modelInference,contextParams: params)
var output=""
try ExceptionCather.catchException {
output = try! ai.model.predict(input_text, mainCallback)
}
// llama_save_session_file(ai.model.context,"/Users/guinmoon/dev/alpaca_llama_etc/dump_state.bin",ai.model.session_tokens, ai.model.session_tokens.count)
// llama_save_state(ai.model.context,"/Users/guinmoon/dev/alpaca_llama_etc/dump_state_.bin")
//
print(output)
}catch {
print (error)
}

return LLMResult()
}

Expand Down

0 comments on commit 3095a06

Please sign in to comment.