Skip to content

Commit fc54032

Browse files
author
Judd
committed
main.nim improved and used as default app.
1 parent ddae963 commit fc54032

File tree

6 files changed

+29
-27
lines changed

6 files changed

+29
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pure C++ implementation based on [@ggerganov](https://github.com/ggerganov)'s [g
4242

4343
## Quick Start
4444

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

4747
## Usage
4848

README_ja.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,6 @@
1010

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

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

2815
* [x] int4/int8 量子化、最適化された KV キャッシュ、並列計算によるメモリ効率の高い CPU 推論の加速

README_zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
## 快速开始
2828

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

3131
## 使用方法
3232

bindings/main.nim

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,17 @@ var storage_dir: string = "../quantized"
147147
var ht = highlighter(line_acc: "", lang: langNone)
148148
let chat = chatllm_create()
149149

150+
# related front end parameters are ignored by `libchatllm`
151+
var prompt: string = "hello"
152+
var interactive: bool = false
153+
150154
for i in 1 .. paramCount():
155+
if paramStr(i) in ["-i", "--interactive"]:
156+
interactive = true
157+
158+
if (i > 1) and (paramStr(i - 1) in ["-p", "--prompt"]):
159+
prompt = paramStr(i)
160+
151161
if (i > 1) and (paramStr(i - 1) in candidates) and paramStr(i).startsWith(":"):
152162
var m = paramStr(i)
153163
m = m[1..<len(m)]
@@ -160,13 +170,18 @@ if r != 0:
160170
echo ">>> chatllm_start error: ", r
161171
quit(r)
162172

163-
while true:
164-
stdout.write("You > ")
165-
let input = stdin.readLine()
166-
if input.isEmptyOrWhitespace(): continue
167-
168-
stdout.write("A.I. > ")
169-
let r = chatllm_user_input(chat, input.cstring)
170-
if r != 0:
171-
echo ">>> chatllm_user_input error: ", r
172-
break
173+
if interactive:
174+
while true:
175+
stdout.write("You > ")
176+
let input = stdin.readLine()
177+
if input.isEmptyOrWhitespace(): continue
178+
179+
stdout.write("A.I. > ")
180+
let r = chatllm_user_input(chat, input.cstring)
181+
if r != 0:
182+
echo ">>> chatllm_user_input error: ", r
183+
break
184+
else:
185+
discard chatllm_user_input(chat, prompt.cstring)
186+
187+
chatllm_show_statistics(chat)

docs/quick_start.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
For Windows users, the easies way is to download a release, extract it, and start chatting:
44

55
```
6-
python chatllm.py -i -m :qwen2:0.5b
7-
downloading qwen2:0.5b
6+
main -i -m :qwen2.5:0.5b
7+
Downloading qwen2:0.5b
88
|████████████████████████████████████████████████████████████| 100.0%
99
________ __ __ __ __ ___ (通义千问)
1010
/ ____/ /_ ____ _/ /_/ / / / / |/ /_________ ____

images/demo.gif

397 KB
Loading

0 commit comments

Comments
 (0)