Commit Graph

39 Commits

Author SHA1 Message Date
lif 93b7ae5fc7
Merge 9ef7d88e8f into 76912c062a 2026-01-06 14:26:27 +05:30
Parth Sareen 76912c062a
x: add experimental agent loop (#13628) 2026-01-05 23:38:40 -08:00
majiayu000 9ef7d88e8f fix: correct cursor positioning when backspacing over line wrap
When backspacing over a line wrap, the cursor was positioned at column
Width (one past the last valid column) instead of Width-1 (the last
character position). This caused the overwrite space character to be
printed at an invalid position, leaving the original character visible
on screen while the buffer correctly had the character deleted.

Fix by changing CursorRightN(b.Width) to CursorRightN(b.Width-1) in the
MoveLeft and Remove functions to position at the actual last column.

Fixes #13587

Signed-off-by: majiayu000 <1835304752@qq.com>
2026-01-02 07:01:39 +08:00
Devon Rifkin 5f57b0ef42
add thinking support to the api and cli (#10584)
- Both `/api/generate` and `/api/chat` now accept a `"think"`
  option that allows specifying whether thinking mode should be on or
  not
- Templates get passed this new option so, e.g., qwen3's template can
  put `/think` or `/no_think` in the system prompt depending on the
  value of the setting
- Models' thinking support is inferred by inspecting model templates.
  The prefix and suffix the parser uses to identify thinking support is
  also automatically inferred from templates
- Thinking control & parsing is opt-in via the API to prevent breaking
  existing API consumers. If the `"think"` option is not specified, the
  behavior is unchanged from previous versions of ollama
- Add parsing for thinking blocks in both streaming/non-streaming mode
  in both `/generate` and `/chat`
- Update the CLI to make use of these changes. Users can pass `--think`
  or `--think=false` to control thinking, or during an interactive
  session they can use the commands `/set think` or `/set nothink`
- A `--hidethinking` option has also been added to the CLI. This makes
  it easy to use thinking in scripting scenarios like
  `ollama run qwen3 --think --hidethinking "my question here"` where you
  just want to see the answer but still want the benefits of thinking
  models
2025-05-28 19:38:52 -07:00
Shane-XB-Qian 6b45b1d6b4
cli: adding support ctrl-n/p like general cli (#9136)
Signed-off-by: shane.xb.qian <shane.qian@foxmail.com>
2025-03-12 08:51:56 -07:00
Michael Yang cb40d60469 chore: upgrade to gods v2
gods v2 uses go generics rather than interfaces which simplifies the
code considerably
2024-12-21 00:05:16 -08:00
Michael Yang 2697d7f5aa lint
- fixes printf: non-constant format string in call to fmt.Printf
- fixes SA1032: arguments have the wrong order
- disables testifylint
2024-08-13 14:36:33 -07:00
Michael Yang b732beba6a lint 2024-08-01 17:06:06 -07:00
Michael Yang 8ce4032e72 more lint 2024-06-04 11:13:30 -07:00
Michael Yang f38353d6b9 stdin.fd 2024-06-04 11:13:30 -07:00
Michael Yang e40145a39d lint 2024-06-04 11:13:30 -07:00
Michael Yang 8ffb51749f nolintlint 2024-06-04 11:13:30 -07:00
Josh ad897080a2
working on integration of multi-byte and multi-width runes (#4549)
* integrated runewidth for display management - fixed cursor movement for mutli-width char

* updated input and deletion of multi-byte chars

* fixed line history with some exceptions

* improved insert and add

* fixed issues with moving across lines

* end of line extra space tracking'

* saved changes

* fixed end of line issues with empty spaces

* worked some more

* worked on end of line

* fixed failed test

* fixed minor inserting bug

* fixed movement hotkeys

* adjusted hotkeys

* removed comments

* Update readline/buffer.go

Co-authored-by: Bruce MacDonald <brucewmacdonald@gmail.com>

* Update readline/buffer.go

Co-authored-by: Bruce MacDonald <brucewmacdonald@gmail.com>

* Update readline/buffer.go

Co-authored-by: Bruce MacDonald <brucewmacdonald@gmail.com>

* Update readline/buffer.go

Co-authored-by: Bruce MacDonald <brucewmacdonald@gmail.com>

* Update readline/buffer.go

Co-authored-by: Bruce MacDonald <brucewmacdonald@gmail.com>

* Update readline/buffer.go

Co-authored-by: Bruce MacDonald <brucewmacdonald@gmail.com>

* Update readline/buffer.go

Co-authored-by: Bruce MacDonald <brucewmacdonald@gmail.com>

* Update readline/buffer.go

Co-authored-by: Bruce MacDonald <brucewmacdonald@gmail.com>

* Update readline/buffer.go

Co-authored-by: Bruce MacDonald <brucewmacdonald@gmail.com>

* Update readline/buffer.go

Co-authored-by: Bruce MacDonald <brucewmacdonald@gmail.com>

* Update readline/buffer.go

Co-authored-by: Bruce MacDonald <brucewmacdonald@gmail.com>

* Update readline/buffer.go

Co-authored-by: Bruce MacDonald <brucewmacdonald@gmail.com>

* deleted comments and duplicate code

* removed duplicate code

* added comments, refactored add function to use addChar

* added helper to retrieve lineSpacing, renamed lineFlags for clarity

* fixed remove()

---------

Co-authored-by: Bruce MacDonald <brucewmacdonald@gmail.com>
2024-05-28 12:04:03 -07:00
Giuseppe Lumia 2a5302a1cf
Fix paste of text with line feed characters (#3043)
Some terminals may send line feed characters when pasting text with
newlines.
2024-05-07 15:26:07 -07:00
Patrick Devine 5a5efee46b
Add gemma safetensors conversion (#3250)
Co-authored-by: Michael Yang <mxyng@pm.me>
2024-03-28 18:54:01 -07:00
Jeffrey Morgan 913306f4fd
Detect arrow keys on windows (#3363)
* detect arrow keys on windows
* add some helpful comments
2024-03-26 18:21:56 -04:00
Blake Mizerany 6ce37e4d96
llm,readline: use errors.Is instead of simple == check (#3161)
This fixes some brittle, simple equality checks to use errors.Is. Since
go1.13, errors.Is is the idiomatic way to check for errors.

Co-authored-by: Jeffrey Morgan <jmorganca@gmail.com>
2024-03-15 07:14:12 -07:00
Michael Yang b1e74d4fda default terminal width, height 2024-03-07 11:35:42 -08:00
Patrick Devine 42e77e2a69
handle race condition while setting raw mode in windows (#2509) 2024-02-14 21:28:35 -08:00
Meng Zhuo 069184562b
readline: drop not use min function (#2134) 2024-01-22 08:15:08 -08:00
Michael Yang f95d2f25f3 fix temporary history file permissions 2024-01-09 09:36:58 -08:00
Michael Yang 2bb2bdd5d4 fix lint 2024-01-09 09:36:58 -08:00
Michael Yang acfc376efd add .golangci.yaml 2024-01-09 09:36:58 -08:00
Michael Yang 2ef9352b94 fix(cmd): history in alt mode 2024-01-05 16:20:02 -08:00
Bruce MacDonald 7a1b37ac64
os specific ctrl-z (#1420) 2023-12-11 10:48:14 -05:00
Michael Yang 88620e983a handle ctrl+z 2023-12-01 16:15:20 -08:00
Jeffrey Morgan e9216ea459 fix readline history on linux 2023-11-26 15:59:04 -05:00
Jeffrey Morgan 9fb5e8399c Fix issues with inputting and formatting multi line strings in `ollama run`
Co-authored-by: Wen Sun <iwendellsun@gmail.com>
2023-11-26 12:54:29 -05:00
Kevin Cao 3cd07728f4
Make alt+backspace delete word (#1223) 2023-11-21 12:26:47 -08:00
Michael Yang f42f3d9b27 go fmt 2023-11-01 11:55:08 -07:00
Bruce MacDonald 0818b5e318
readline windows terminal support (#950)
- update the readline package to have basic support on windows, this is not full feature parity with the unix cli yet
2023-10-30 16:18:12 -04:00
Jeffrey Morgan 8d03bd7b54 remove `+build` directive in `term.go` 2023-10-28 09:56:03 -07:00
Jeffrey Morgan 9ec16f0f03 fix formatting when exiting `ollama run` 2023-10-27 21:26:23 -07:00
Jeffrey Morgan 57a58db1b0 history: update pos after compact 2023-10-27 20:38:03 -07:00
Jeffrey Morgan 2d75a4537c close input channel when receiving `io.EOF` 2023-10-27 20:26:04 -07:00
Jeffrey Morgan 4748609611
Don't quit ioloop on `NUL` character (#940)
* dont quit ioloop on 0 rune

* check for closed channel

* remove unused error on `Close()`
2023-10-27 20:01:48 -07:00
Patrick Devine a79f030e75
add bracketed paste mode (#922) 2023-10-26 15:57:00 -07:00
Patrick Devine 5b2cf16397
fix docker build annotations (#917) 2023-10-26 12:00:33 -07:00
Patrick Devine deeac961bb
new readline library (#847) 2023-10-25 16:41:18 -07:00