Skip to content

Commit

Permalink
main.nim improved and used as default app.
Browse files Browse the repository at this point in the history
  • Loading branch information
Judd committed Nov 26, 2024
1 parent ddae963 commit fc54032
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pure C++ implementation based on [@ggerganov](https://github.com/ggerganov)'s [g

## Quick Start

As simple as `python chatllm.py -i -m :model_id`. [Check it out](./docs/quick_start.md).
As simple as `main -i -m :model_id`. [Check it out](./docs/quick_start.md).

## Usage

Expand Down
13 changes: 0 additions & 13 deletions README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,6 @@

| [サポートされているモデル](./docs/models.md) | [量子化モデルのダウンロード](./docs/quick_start.md#download-quantized-models) |

**新着情報:**

* 2024-11-01: Granite, [生成ステアリング](./docs/fun.md#generation-steering)
* 2024-09-29: LlaMA 3.2
* 2024-09-22: Qwen 2.5
* 2024-09-13: OLMoE
* 2024-09-11: MiniCPM3
* 2024-07-14: [ggml 更新](https://github.com/ggerganov/ggml/tree/3e7e5e26f90fecf4f7c2808df7d94454630b219c)
* 2024-06-15: [ツール呼び出し](./docs/tool_calling.md)
* 2024-05-29: [ggml](https://github.com/ggerganov/ggml) はサブモジュールではなくフォークされました
* 2024-05-14: [OpenAI API](./docs/binding.md#openai-compatible-api), CodeGemma Base & Instruct 対応
* 2024-05-08: [レイヤーシャッフル](./docs/fun.md#layer-shuffling)

## 特徴

* [x] int4/int8 量子化、最適化された KV キャッシュ、並列計算によるメモリ効率の高い CPU 推論の加速
Expand Down
2 changes: 1 addition & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

## 快速开始

只需要简单一行 `python chatllm.py -i -m :model_id`. 查看 [详情](./docs/quick_start.md).
只需要简单一行 `main -i -m :model_id`. 查看 [详情](./docs/quick_start.md).

## 使用方法

Expand Down
35 changes: 25 additions & 10 deletions bindings/main.nim
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,17 @@ var storage_dir: string = "../quantized"
var ht = highlighter(line_acc: "", lang: langNone)
let chat = chatllm_create()

# related front end parameters are ignored by `libchatllm`
var prompt: string = "hello"
var interactive: bool = false

for i in 1 .. paramCount():
if paramStr(i) in ["-i", "--interactive"]:
interactive = true

if (i > 1) and (paramStr(i - 1) in ["-p", "--prompt"]):
prompt = paramStr(i)

if (i > 1) and (paramStr(i - 1) in candidates) and paramStr(i).startsWith(":"):
var m = paramStr(i)
m = m[1..<len(m)]
Expand All @@ -160,13 +170,18 @@ if r != 0:
echo ">>> chatllm_start error: ", r
quit(r)

while true:
stdout.write("You > ")
let input = stdin.readLine()
if input.isEmptyOrWhitespace(): continue

stdout.write("A.I. > ")
let r = chatllm_user_input(chat, input.cstring)
if r != 0:
echo ">>> chatllm_user_input error: ", r
break
if interactive:
while true:
stdout.write("You > ")
let input = stdin.readLine()
if input.isEmptyOrWhitespace(): continue

stdout.write("A.I. > ")
let r = chatllm_user_input(chat, input.cstring)
if r != 0:
echo ">>> chatllm_user_input error: ", r
break
else:
discard chatllm_user_input(chat, prompt.cstring)

chatllm_show_statistics(chat)
4 changes: 2 additions & 2 deletions docs/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
For Windows users, the easies way is to download a release, extract it, and start chatting:

```
python chatllm.py -i -m :qwen2:0.5b
downloading qwen2:0.5b
main -i -m :qwen2.5:0.5b
Downloading qwen2:0.5b
|████████████████████████████████████████████████████████████| 100.0%
________ __ __ __ __ ___ (通义千问)
/ ____/ /_ ____ _/ /_/ / / / / |/ /_________ ____
Expand Down
Binary file added images/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fc54032

Please sign in to comment.