Skip to content

Commit cb24993

Browse files
committed
use kvql instead of query, and remove go-llama
1 parent 256e7d6 commit cb24993

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+21
-11016
lines changed

.gitmodules

-3
This file was deleted.

Makefile

-7
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,3 @@ endif
1010

1111
check:
1212
golint -set_exit_status .
13-
14-
prepare-llama-cpp:
15-
cd thirdparty/go-llama.cpp; git submodule update --init --recursive
16-
cd thirdparty/go-llama.cpp; make libbinding.a
17-
18-
build-with-llama: prepare-llama-cpp
19-
LIBRARY_PATH=./thirdparty/go-llama.cpp C_INCLUDE_PATH=./thirdparty/go-llama.cpp $(CGO_FLAGS) go build -tags "llama,$(TAGS)" -o bin/tcli ./cli/*.go

README.md

+1-22
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,4 @@ Input: scanp hello
8282
|-------------|-------|
8383
2 Records Found
8484
Success, Elapse: 5 ms
85-
```
86-
87-
5. Play With LLama
88-
89-
Build tcli with LLama
90-
91-
```
92-
make build-with-llama
93-
```
94-
95-
Then you can start `tcli` and then use `ask` command to ask questions to LLama
96-
97-
```
98-
LLAMA_PATH=/data/models/llama-2-7b.ggmlv3.q4_0.bin bin/tcli
99-
100-
>>> ask who are you?
101-
...
102-
```
103-
104-
The `LLAMA_PATH` environment variable is tell `tcli` where to load LLama2 model.
105-
106-
And you can also use `embedding` function in `query` command
85+
```

cli/cmd_llama.go

-98
This file was deleted.

go.mod

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
module github.com/c4pt0r/tcli
22

3-
go 1.21
3+
go 1.21.1
44

55
require (
66
github.com/AlecAivazis/survey/v2 v2.2.16
77
github.com/abiosoft/ishell v2.0.0+incompatible
88
github.com/beorn7/perks v1.0.1
99
github.com/c4pt0r/log v0.0.0-20211004143616-aa6380016a47
1010
github.com/fatih/color v1.12.0
11-
github.com/go-skynet/go-llama.cpp v0.0.0-20231009155254-aeba71ee8428
1211
github.com/magiconair/properties v1.8.0
1312
github.com/manifoldco/promptui v0.8.0
1413
github.com/olekukonko/tablewriter v0.0.5
@@ -22,6 +21,7 @@ require (
2221

2322
require (
2423
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db // indirect
24+
github.com/c4pt0r/kvql v0.0.0-20240428025121-0619eade54de // indirect
2525
github.com/cespare/xxhash/v2 v2.1.1 // indirect
2626
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
2727
github.com/coreos/go-semver v0.3.0 // indirect
@@ -67,5 +67,3 @@ require (
6767
google.golang.org/grpc v1.27.1 // indirect
6868
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
6969
)
70-
71-
replace github.com/go-skynet/go-llama.cpp => ./thirdparty/go-llama.cpp

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
5454
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k=
5555
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
5656
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
57+
github.com/c4pt0r/kvql v0.0.0-20240428025121-0619eade54de h1:A3Z6rWtCNh81gaMpGb9qzhvFtCOTIdsGV1JK/lANsiw=
58+
github.com/c4pt0r/kvql v0.0.0-20240428025121-0619eade54de/go.mod h1:ksAcL0FG13v+9UVAznpGjkIh2yB3qUSkgoNR4aPrl9w=
5759
github.com/c4pt0r/log v0.0.0-20211004143616-aa6380016a47 h1:I7bb8MbleLvoW6scHXngCQaroNa9slYTaYOaQEsv2TQ=
5860
github.com/c4pt0r/log v0.0.0-20211004143616-aa6380016a47/go.mod h1:N78ACK7UQq5KjTLWQPw2A7UuzX712vN9akunb8ydlck=
5961
github.com/cakturk/go-netstat v0.0.0-20200220111822-e5b49efee7a5 h1:BjkPE3785EwPhhyuFkbINB+2a1xATwk8SNDWnJiD41g=

kvcmds/cmd_explain.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55

66
"github.com/c4pt0r/tcli"
7+
"github.com/c4pt0r/kvql"
78
"github.com/c4pt0r/tcli/client"
89
"github.com/c4pt0r/tcli/query"
910
"github.com/c4pt0r/tcli/utils"
@@ -41,7 +42,7 @@ func (c ExplainCmd) Handler() func(ctx context.Context) {
4142
}
4243
sql := getQueryString(ic)
4344
qtxn := query.NewQueryTxn(client.GetTiKVClient())
44-
opt := query.NewOptimizer(sql)
45+
opt := kvql.NewOptimizer(sql)
4546
plan, err := opt.BuildPlan(qtxn)
4647
if err != nil {
4748
return bindQueryToError(sql, err)

kvcmds/cmd_query.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/abiosoft/ishell"
1010
"github.com/c4pt0r/tcli"
1111
"github.com/c4pt0r/tcli/client"
12+
"github.com/c4pt0r/kvql"
1213
"github.com/c4pt0r/tcli/query"
1314
"github.com/c4pt0r/tcli/utils"
1415
)
@@ -43,7 +44,7 @@ func getQueryString(ic *ishell.Context) string {
4344
return strings.Join(ret, " ")
4445
}
4546

46-
func convertColumnToString(c query.Column) string {
47+
func convertColumnToString(c kvql.Column) string {
4748
switch v := c.(type) {
4849
case int, int8, int16, int32, int64,
4950
uint, uint8, uint16, uint32, uint64:
@@ -59,7 +60,7 @@ func convertColumnToString(c query.Column) string {
5960
return "true"
6061
}
6162
return "false"
62-
case map[string]any, query.JSON, []any, []string, []int64, []float32, []float64:
63+
case map[string]any, kvql.JSON, []any, []string, []int64, []float32, []float64:
6364
return fmt.Sprintf("%v", v)
6465
default:
6566
if v == nil {
@@ -79,7 +80,7 @@ func (c QueryCmd) Handler() func(ctx context.Context) {
7980
}
8081
sql := getQueryString(ic)
8182
qtxn := query.NewQueryTxn(client.GetTiKVClient())
82-
opt := query.NewOptimizer(sql)
83+
opt := kvql.NewOptimizer(sql)
8384
plan, err := opt.BuildPlan(qtxn)
8485
if err != nil {
8586
return bindQueryToError(sql, err)
@@ -102,19 +103,19 @@ func (c QueryCmd) Handler() func(ctx context.Context) {
102103

103104
func bindQueryToError(sql string, err error) error {
104105
switch val := err.(type) {
105-
case query.QueryBinder:
106+
case kvql.QueryBinder:
106107
val.BindQuery(sql)
107108
return err
108109
default:
109110
return err
110111
}
111112
}
112113

113-
func (c QueryCmd) getRows(plan query.FinalPlan) ([][]string, error) {
114+
func (c QueryCmd) getRows(plan kvql.FinalPlan) ([][]string, error) {
114115
ret := [][]string{
115116
plan.FieldNameList(),
116117
}
117-
ectx := query.NewExecuteCtx()
118+
ectx := kvql.NewExecuteCtx()
118119
for {
119120
cols, err := plan.Next(ectx)
120121
if err != nil {
@@ -134,11 +135,11 @@ func (c QueryCmd) getRows(plan query.FinalPlan) ([][]string, error) {
134135
return ret, nil
135136
}
136137

137-
func (c QueryCmd) getRowsBatch(plan query.FinalPlan) ([][]string, error) {
138+
func (c QueryCmd) getRowsBatch(plan kvql.FinalPlan) ([][]string, error) {
138139
ret := [][]string{
139140
plan.FieldNameList(),
140141
}
141-
ectx := query.NewExecuteCtx()
142+
ectx := kvql.NewExecuteCtx()
142143
for {
143144
rows, err := plan.Batch(ectx)
144145
if err != nil {

0 commit comments

Comments
 (0)