WE GOT AI
parent
a48518fea6
commit
046dc0e1ba
3
ai.go
3
ai.go
|
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
nn "github.com/nikolaydubina/llama2.go/exp/nnfast"
|
nn "github.com/nikolaydubina/llama2.go/exp/nnfast"
|
||||||
|
|
@ -132,5 +131,5 @@ func (ai AILocal) Do(ctx context.Context, prompt string) (string, error) {
|
||||||
}
|
}
|
||||||
out.Write([]byte("\n"))
|
out.Write([]byte("\n"))
|
||||||
|
|
||||||
return string(out.Bytes()), errors.New("not impl")
|
return string(out.Bytes()), nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
38
ai_test.go
38
ai_test.go
|
|
@ -4,6 +4,10 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
@ -12,9 +16,39 @@ func TestAILocal(t *testing.T) {
|
||||||
ctx, can := context.WithTimeout(context.Background(), time.Minute)
|
ctx, can := context.WithTimeout(context.Background(), time.Minute)
|
||||||
defer can()
|
defer can()
|
||||||
|
|
||||||
|
d := os.TempDir()
|
||||||
|
for k, u := range map[string]string{
|
||||||
|
"checkpoints": "https://huggingface.co/karpathy/tinyllamas/resolve/main/stories110M.bin",
|
||||||
|
"tokenizer": "https://github.com/karpathy/llama2.c/raw/master/tokenizer.bin",
|
||||||
|
} {
|
||||||
|
func() {
|
||||||
|
if _, err := os.Stat(path.Join(d, k)); os.IsNotExist(err) {
|
||||||
|
t.Logf("downloading %s from %s", u, k)
|
||||||
|
|
||||||
|
resp, err := http.Get(u)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
f, err := os.Create(path.Join(d, k))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
if _, err := io.Copy(f, resp.Body); err != nil {
|
||||||
|
f.Close()
|
||||||
|
os.Remove(path.Join(d, k))
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
ai := NewAILocal(
|
ai := NewAILocal(
|
||||||
"checkpointPath",
|
path.Join(d, "checkpoints"),
|
||||||
"tokenizerPath",
|
path.Join(d, "tokenizer"),
|
||||||
0.9,
|
0.9,
|
||||||
256,
|
256,
|
||||||
0.9,
|
0.9,
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ func (s Storage) ThreadsSince(ctx context.Context, t time.Time) ([]string, error
|
||||||
for k := range threads {
|
for k := range threads {
|
||||||
result = append(result, k)
|
result = append(result, k)
|
||||||
}
|
}
|
||||||
|
sort.Strings(result)
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue