From 17b1e81ca13bc386be182fdc93d59d50e978fb85 Mon Sep 17 00:00:00 2001 From: Josh Yan Date: Wed, 15 May 2024 16:29:33 -0700 Subject: [PATCH 1/9] fixed width and word count for double spacing --- cmd/cmd.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index cae35f51..1606e9f1 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -25,7 +25,7 @@ import ( "time" "github.com/containerd/console" - + "github.com/mattn/go-runewidth" "github.com/olekukonko/tablewriter" "github.com/spf13/cobra" "golang.org/x/crypto/ssh" @@ -739,12 +739,13 @@ type displayResponseState struct { wordBuffer string } +// using runewidth instead of len (cus length is number of bytes, we wnat display length) func displayResponse(content string, wordWrap bool, state *displayResponseState) { termWidth, _, _ := term.GetSize(int(os.Stdout.Fd())) if wordWrap && termWidth >= 10 { for _, ch := range content { - if state.lineLength+1 > termWidth-5 { - if len(state.wordBuffer) > termWidth-10 { + if state.lineLength+1 > termWidth - 5 { + if runewidth.StringWidth(state.wordBuffer) > termWidth - 10 { fmt.Printf("%s%c", state.wordBuffer, ch) state.wordBuffer = "" state.lineLength = 0 @@ -752,12 +753,18 @@ func displayResponse(content string, wordWrap bool, state *displayResponseState) } // backtrack the length of the last word and clear to the end of the line - fmt.Printf("\x1b[%dD\x1b[K\n", len(state.wordBuffer)) + fmt.Printf("\x1b[%dD\x1b[K\n", runewidth.StringWidth(state.wordBuffer)) fmt.Printf("%s%c", state.wordBuffer, ch) - state.lineLength = len(state.wordBuffer) + 1 + chWidth := runewidth.RuneWidth(ch) + + state.lineLength = runewidth.StringWidth(state.wordBuffer) + chWidth } else { fmt.Print(string(ch)) - state.lineLength += 1 + state.lineLength += runewidth.RuneWidth(ch) + if runewidth.RuneWidth(ch) >= 2 { + state.wordBuffer = "" + continue + } switch ch { case ' ': From c9e584fb9009faff2b1f2e38b4c7ab86a7d150b1 Mon Sep 17 00:00:00 2001 From: Josh Yan Date: Wed, 15 May 2024 16:45:24 -0700 Subject: [PATCH 2/9] updated double-width display --- cmd/cmd.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/cmd.go b/cmd/cmd.go index 1606e9f1..91a77c79 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -745,6 +745,7 @@ func displayResponse(content string, wordWrap bool, state *displayResponseState) if wordWrap && termWidth >= 10 { for _, ch := range content { if state.lineLength+1 > termWidth - 5 { + if runewidth.StringWidth(state.wordBuffer) > termWidth - 10 { fmt.Printf("%s%c", state.wordBuffer, ch) state.wordBuffer = "" From 799aa9883cd9d33b44e7ab64540093a9a4e3cbab Mon Sep 17 00:00:00 2001 From: Josh Yan Date: Wed, 15 May 2024 17:24:17 -0700 Subject: [PATCH 3/9] go fmt'd cmd.go --- cmd/cmd.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index 91a77c79..a0ae86d3 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -744,9 +744,9 @@ func displayResponse(content string, wordWrap bool, state *displayResponseState) termWidth, _, _ := term.GetSize(int(os.Stdout.Fd())) if wordWrap && termWidth >= 10 { for _, ch := range content { - if state.lineLength+1 > termWidth - 5 { + if state.lineLength+1 > termWidth-5 { - if runewidth.StringWidth(state.wordBuffer) > termWidth - 10 { + if runewidth.StringWidth(state.wordBuffer) > termWidth-10 { fmt.Printf("%s%c", state.wordBuffer, ch) state.wordBuffer = "" state.lineLength = 0 @@ -765,7 +765,7 @@ func displayResponse(content string, wordWrap bool, state *displayResponseState) if runewidth.RuneWidth(ch) >= 2 { state.wordBuffer = "" continue - } + } switch ch { case ' ': From 26bfc1c443ce178fa009747b2cf83ad9876d5a6a Mon Sep 17 00:00:00 2001 From: Josh Yan Date: Wed, 15 May 2024 17:26:39 -0700 Subject: [PATCH 4/9] go fmt'd cmd.go --- cmd/cmd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index a0ae86d3..8917022e 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -739,7 +739,7 @@ type displayResponseState struct { wordBuffer string } -// using runewidth instead of len (cus length is number of bytes, we wnat display length) +// using runewidth instead of len (cus length is number of bytes, we want display length) func displayResponse(content string, wordWrap bool, state *displayResponseState) { termWidth, _, _ := term.GetSize(int(os.Stdout.Fd())) if wordWrap && termWidth >= 10 { From 583c1f472cbc22bd4869bc5f774c7ac777deedc7 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Thu, 16 May 2024 13:53:09 -0700 Subject: [PATCH 5/9] update llama.cpp submodule to `614d3b9` (#4414) --- llm/llama.cpp | 2 +- llm/patches/05-clip-fix.diff | 24 ------------------------ 2 files changed, 1 insertion(+), 25 deletions(-) delete mode 100644 llm/patches/05-clip-fix.diff diff --git a/llm/llama.cpp b/llm/llama.cpp index 952d03db..614d3b91 160000 --- a/llm/llama.cpp +++ b/llm/llama.cpp @@ -1 +1 @@ -Subproject commit 952d03dbead16e4dbdd1d3458486340673cc2465 +Subproject commit 614d3b914e1c3e02596f869649eb4f1d3b68614d diff --git a/llm/patches/05-clip-fix.diff b/llm/patches/05-clip-fix.diff deleted file mode 100644 index 3f68a5bb..00000000 --- a/llm/patches/05-clip-fix.diff +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/examples/llava/clip.cpp b/examples/llava/clip.cpp -index e3c9bcd4..b43f892d 100644 ---- a/examples/llava/clip.cpp -+++ b/examples/llava/clip.cpp -@@ -573,14 +573,16 @@ static ggml_cgraph * clip_image_build_graph(clip_ctx * ctx, const clip_image_f32 - struct ggml_tensor * embeddings = inp; - if (ctx->has_class_embedding) { - embeddings = ggml_new_tensor_3d(ctx0, GGML_TYPE_F32, hidden_size, num_positions, batch_size); -+ } -+ ggml_set_name(embeddings, "embeddings"); -+ ggml_set_input(embeddings); -+ -+ if (ctx->has_class_embedding) { - embeddings = ggml_acc(ctx0, embeddings, model.class_embedding, - embeddings->nb[1], embeddings->nb[2], embeddings->nb[3], 0); - embeddings = ggml_acc(ctx0, embeddings, inp, - embeddings->nb[1], embeddings->nb[2], embeddings->nb[3], model.class_embedding->nb[1]); - } -- ggml_set_name(embeddings, "embeddings"); -- ggml_set_input(embeddings); -- - - struct ggml_tensor * positions = ggml_new_tensor_1d(ctx0, GGML_TYPE_I32, num_positions); - ggml_set_name(positions, "positions"); From 5e46c5c43502ef6174dde00dbdd9008d8f713cd1 Mon Sep 17 00:00:00 2001 From: Rose Heart <89426212+rapmd73@users.noreply.github.com> Date: Thu, 16 May 2024 15:55:14 -0500 Subject: [PATCH 6/9] Updating software for read me (#4467) * Update README.md Added chat/moderation bot to list of software. * Update README.md Fixed link error. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 034760e1..5d3daec5 100644 --- a/README.md +++ b/README.md @@ -391,6 +391,7 @@ See the [API documentation](./docs/api.md) for all endpoints. - [AI Telegram Bot](https://github.com/tusharhero/aitelegrambot) (Telegram bot using Ollama in backend) - [AI ST Completion](https://github.com/yaroslavyaroslav/OpenAI-sublime-text) (Sublime Text 4 AI assistant plugin with Ollama support) - [Discord-Ollama Chat Bot](https://github.com/kevinthedang/discord-ollama) (Generalized TypeScript Discord Bot w/ Tuning Documentation) +- [Discord AI chat/moderation bot](https://github.com/rapmd73/Companion) Chat/moderation bot written in python. Uses Ollama to create personalities. ### Supported backends - [llama.cpp](https://github.com/ggerganov/llama.cpp) project founded by Georgi Gerganov. From 3d90156e997dd5daec727152f0cc85f26cc91342 Mon Sep 17 00:00:00 2001 From: Josh Yan Date: Thu, 16 May 2024 14:12:03 -0700 Subject: [PATCH 7/9] removed comment --- cmd/cmd.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index 8917022e..dff8d7c1 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -739,7 +739,6 @@ type displayResponseState struct { wordBuffer string } -// using runewidth instead of len (cus length is number of bytes, we want display length) func displayResponse(content string, wordWrap bool, state *displayResponseState) { termWidth, _, _ := term.GetSize(int(os.Stdout.Fd())) if wordWrap && termWidth >= 10 { From 7f2fbad73625bfc3039019a1630f1ddf5778df75 Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Thu, 16 May 2024 16:24:18 -0700 Subject: [PATCH 8/9] Skip max queue test on remote This test needs to be able to adjust the queue size down from our default setting for a reliable test, so it needs to skip on remote test execution mode. --- integration/max_queue_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/integration/max_queue_test.go b/integration/max_queue_test.go index 43b15c6c..dfa5eae0 100644 --- a/integration/max_queue_test.go +++ b/integration/max_queue_test.go @@ -19,6 +19,11 @@ import ( ) func TestMaxQueue(t *testing.T) { + if os.Getenv("OLLAMA_TEST_EXISTING") != "" { + t.Skip("Max Queue test requires spawing a local server so we can adjust the queue size") + return + } + // Note: This test can be quite slow when running in CPU mode, so keep the threadCount low unless your on GPU // Also note that by default Darwin can't sustain > ~128 connections without adjusting limits threadCount := 32 @@ -109,9 +114,9 @@ func TestMaxQueue(t *testing.T) { slog.Info("generate done, waiting for embeds") embedwg.Wait() + slog.Info("embeds completed", "success", succesCount, "busy", busyCount, "reset", resetByPeerCount, "canceled", canceledCount) require.Equal(t, resetByPeerCount, 0, "Connections reset by peer, have you updated your fd and socket limits?") require.True(t, busyCount > 0, "no requests hit busy error but some should have") require.True(t, canceledCount == 0, "no requests should have been canceled due to timeout") - slog.Info("embeds completed", "success", succesCount, "busy", busyCount, "reset", resetByPeerCount, "canceled", canceledCount) } From 02b31c9dc803e6c14a0d781d276f179b6c34d6f2 Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Thu, 16 May 2024 16:25:38 -0700 Subject: [PATCH 9/9] Don't return error on signal exit --- server/routes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/routes.go b/server/routes.go index e991e774..5fbc2b54 100644 --- a/server/routes.go +++ b/server/routes.go @@ -1086,7 +1086,7 @@ func Serve(ln net.Listener) error { return err } <-ctx.Done() - return err + return nil } func waitForStream(c *gin.Context, ch chan interface{}) {