mirror of
https://github.com/nomic-ai/gpt4all
synced 2024-11-02 09:40:42 +00:00
d101ca06d4
* Update README.md fix golang gpt4all import path Signed-off-by: Nandakumar <nandagunasekaran@gmail.com> * Update README.md Signed-off-by: Nandakumar <nandagunasekaran@gmail.com> --------- Signed-off-by: Nandakumar <nandagunasekaran@gmail.com> |
||
---|---|---|
.. | ||
example | ||
binding.cpp | ||
binding.h | ||
go.mod | ||
go.sum | ||
gpt4all_suite_test.go | ||
gpt4all_test.go | ||
gpt4all.go | ||
Makefile | ||
options.go | ||
placeholder | ||
README.md |
GPT4All Golang bindings
The golang bindings have been tested on:
- MacOS
- Linux
Usage
import (
"github.com/nomic-ai/gpt4all/gpt4all-bindings/golang"
)
func main() {
// Load the model
model, err := gpt4all.New("model.bin", gpt4all.SetModelType(gpt4all.GPTJType))
if err != nil {
panic(err)
}
defer model.Free()
model.SetTokenCallback(func(s string) bool {
fmt.Print(s)
return true
})
_, err = model.Predict("Here are 4 steps to create a website:", gpt4all.SetTemperature(0.1))
if err != nil {
panic(err)
}
}
Building
In order to use the bindings you will need to build libgpt4all.a
:
git clone https://github.com/nomic-ai/gpt4all
cd gpt4all/gpt4all-bindings/golang
make libgpt4all.a
To use the bindings in your own software:
- Import
github.com/nomic-ai/gpt4all/gpt4all-bindings/golang
; - Compile
libgpt4all.a
(you can usemake libgpt4all.a
in the bindings/go directory); - Link your go binary against whisper by setting the environment variables
C_INCLUDE_PATH
andLIBRARY_PATH
to point to thebinding.h
file directory andlibgpt4all.a
file directory respectively.
Testing
To run tests, run make test
:
git clone https://github.com/nomic-ai/gpt4all
cd gpt4all/gpt4all-bindings/golang
make test