[GH-ISSUE #6120] Outputting the response leaves a bunch of control characters. #3824

Closed
opened 2026-04-12 14:39:23 -05:00 by GiteaMirror · 9 comments
Owner

Originally created by @jjasghar on GitHub (Aug 1, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/6120

Originally assigned to: @dhiltgen on GitHub.

          I get a bunch of control characters.  How can I get a clean output?

Originally posted by @pongnguy in https://github.com/ollama/ollama/issues/1710#issuecomment-2142294830

It seems when you run something like: ollama run granite-code:20b show me a python fuction that does fizzbuzz > out.txt you end up with a bunch of:

^[[?25l^[[?25hThis^[[?25l^[[?25h function^[[?25l^[[?25h takes^[[?2
5l^[[?25h a^[[?25l^[[?25h positive^[[?25l^[[?25h integer^[[?25l^[[
?25h `^[[?25l^[[?25hn^[[?25l^[[?25h`^[[?25l^[[?25h as^[[?25l^[[?25
h input^[[?25l^[[?25h and^[[?25l^[[?25h prints^[[?25l^[[?25h the^[
[?25l^[[?25h numbers^[[?25l^[[?25h from^[[?25l^[[?25h ^[[?25l^[[?2
5h1^[[?25l^[[?25h to^[[?25l^[[?25h `^[[?25l^[[?25hn^[[?25l^[[?25h`
,^[[?25l^[[?25h replacing^[[?25l^[[?25h multip^[[?25l^[[?25hles^[[
?25l^[[?25h of^[[?25l^[[?25h ^[[?25l^[[?25h3^[[?25l^[[?25h with^[[
?25l^[[?25h "^[[?25l^[[?25hF^[[?25l^[[?25hizz^[[?25l^[[?25h",^[[?2
5l^[[?25h multip^[[?25l^[[?25hles^[[?25l^[[?25h of^[[?25l^[[?25h ^
[[?25l^[[?25h5^[[?25l^[[?25h with^[[?25l^[[?25h 

Over and over. If you try to do the --json output, it's no better. It would be nice to have the simple text output with nothing else.

Originally created by @jjasghar on GitHub (Aug 1, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/6120 Originally assigned to: @dhiltgen on GitHub. I get a bunch of control characters. How can I get a clean output? _Originally posted by @pongnguy in https://github.com/ollama/ollama/issues/1710#issuecomment-2142294830_ It seems when you run something like: `ollama run granite-code:20b show me a python fuction that does fizzbuzz > out.txt` you end up with a bunch of: ``` ^[[?25l^[[?25hThis^[[?25l^[[?25h function^[[?25l^[[?25h takes^[[?2 5l^[[?25h a^[[?25l^[[?25h positive^[[?25l^[[?25h integer^[[?25l^[[ ?25h `^[[?25l^[[?25hn^[[?25l^[[?25h`^[[?25l^[[?25h as^[[?25l^[[?25 h input^[[?25l^[[?25h and^[[?25l^[[?25h prints^[[?25l^[[?25h the^[ [?25l^[[?25h numbers^[[?25l^[[?25h from^[[?25l^[[?25h ^[[?25l^[[?2 5h1^[[?25l^[[?25h to^[[?25l^[[?25h `^[[?25l^[[?25hn^[[?25l^[[?25h` ,^[[?25l^[[?25h replacing^[[?25l^[[?25h multip^[[?25l^[[?25hles^[[ ?25l^[[?25h of^[[?25l^[[?25h ^[[?25l^[[?25h3^[[?25l^[[?25h with^[[ ?25l^[[?25h "^[[?25l^[[?25hF^[[?25l^[[?25hizz^[[?25l^[[?25h",^[[?2 5l^[[?25h multip^[[?25l^[[?25hles^[[?25l^[[?25h of^[[?25l^[[?25h ^ [[?25l^[[?25h5^[[?25l^[[?25h with^[[?25l^[[?25h ``` Over and over. If you try to do the `--json` output, it's no better. It would be nice to have the simple text output with nothing else.
GiteaMirror added the bug label 2026-04-12 14:39:23 -05:00
Author
Owner

@jjasghar commented on GitHub (Aug 1, 2024):

OK, it seems that worked....

➜  docs git:(main) ollama run granite-code:20b show me a python fuction that does fizzbuzz > out.txt
➜  docs git:(main) ✗ cat out.txt
Sure! Here's an example of a Python function that implements the FizzBuzz game:

def fizzbuzz(n):
    for i in range(1, n+1):
        if (i % 3 == 0 and i % 5 == 0):
            print("FizzBuzz")
        elif (i % 3 == 0):
            print("Fizz")
        elif (i % 5 == 0):
            print("Buzz")
        else:
            print(i)

To use this function, simply call it with the desired number of iterations as an argument. For example, `fizzbuzz(15)` will output the numbers from 1 to 15, replacing multiples of 3 with "Fizz", multiples of 5 with "Buzz", and multiples of both 3 and 5 with "FizzBuzz".

When I run it in my vim session:

:r !ollama run granite-code:20b show me a python fuction that does fizzbuzz

The control characters appear. Maybe this is due to a terminal option?

<!-- gh-comment-id:2263220716 --> @jjasghar commented on GitHub (Aug 1, 2024): OK, it seems that worked.... ``` ➜ docs git:(main) ollama run granite-code:20b show me a python fuction that does fizzbuzz > out.txt ➜ docs git:(main) ✗ cat out.txt Sure! Here's an example of a Python function that implements the FizzBuzz game: def fizzbuzz(n): for i in range(1, n+1): if (i % 3 == 0 and i % 5 == 0): print("FizzBuzz") elif (i % 3 == 0): print("Fizz") elif (i % 5 == 0): print("Buzz") else: print(i) To use this function, simply call it with the desired number of iterations as an argument. For example, `fizzbuzz(15)` will output the numbers from 1 to 15, replacing multiples of 3 with "Fizz", multiples of 5 with "Buzz", and multiples of both 3 and 5 with "FizzBuzz". ``` When I run it in my `vim` session: ```vim :r !ollama run granite-code:20b show me a python fuction that does fizzbuzz ``` The control characters appear. Maybe this is due to a terminal option?
Author
Owner

@rick-github commented on GitHub (Aug 1, 2024):

Is your "ollama" command an alias or a wrapper around a docker command? I've seen output with those control codes (ANSI cursor control) when invoking ollama inside a docker container.

This looks fine to the unaided eye:

$ docker exec -t ollama ollama run qwen2:0.5b hi
Hello! How can I assist you today?

But if you examine the actual bytes:

$ docker exec -t ollama ollama run qwen2:0.5b hi | cat -v
^[[?25lM-bM- M-^Y ^[[?25h^[[?25l^[[?25l^[[2K^[[1G^[[?25h^[[2K^[[1G^[[?25hHello^[[?25l^[[?25h!^[[?25l^[[?25h How^[[?25l^[[?25h can^[[?25l^[[?25h I^[[?25l^[[?25h assist^[[?25l^[[?25h you^[[?25l^[[?25h today^[[?25l^[[?25h?^[[?25l^[[?25h^M
^M
^[[?25l^[[?25h

So in your example, your out.txt file might actually contain control codes, it's just that the terminal interprets them when you cat the file and you don't see them. When you pipe the input into a vi buffer, the editor displays them rather than interpreting them.

This seems to be a function of docker, I couldn't find a way to suppress them and eventually just installed a local copy of ollama for those few times I wanted a CLI connection to the ollama server.

$ curl -L -o ~/bin/ollama https://ollama.com/download/ollama-linux-amd64 && chmod +x ~/bin/ollama
$ ~/bin/ollama run qwen2:0.5b hi | cat -v
Hello! How can I help you today?

Another option would a shell script called ollama that gathered the command line arguments and called the API via curl or wget.

<!-- gh-comment-id:2263423708 --> @rick-github commented on GitHub (Aug 1, 2024): Is your "ollama" command an alias or a wrapper around a `docker` command? I've seen output with those control codes (ANSI cursor control) when invoking ollama inside a docker container. This looks fine to the unaided eye: ``` $ docker exec -t ollama ollama run qwen2:0.5b hi Hello! How can I assist you today? ``` But if you examine the actual bytes: ``` $ docker exec -t ollama ollama run qwen2:0.5b hi | cat -v ^[[?25lM-bM- M-^Y ^[[?25h^[[?25l^[[?25l^[[2K^[[1G^[[?25h^[[2K^[[1G^[[?25hHello^[[?25l^[[?25h!^[[?25l^[[?25h How^[[?25l^[[?25h can^[[?25l^[[?25h I^[[?25l^[[?25h assist^[[?25l^[[?25h you^[[?25l^[[?25h today^[[?25l^[[?25h?^[[?25l^[[?25h^M ^M ^[[?25l^[[?25h ``` So in your example, your `out.txt` file might actually contain control codes, it's just that the terminal interprets them when you `cat` the file and you don't see them. When you pipe the input into a vi buffer, the editor displays them rather than interpreting them. This seems to be a function of `docker`, I couldn't find a way to suppress them and eventually just installed a local copy of `ollama` for those few times I wanted a CLI connection to the ollama server. ``` $ curl -L -o ~/bin/ollama https://ollama.com/download/ollama-linux-amd64 && chmod +x ~/bin/ollama $ ~/bin/ollama run qwen2:0.5b hi | cat -v Hello! How can I help you today? ``` Another option would a shell script called `ollama` that gathered the command line arguments and called the API via `curl` or `wget`.
Author
Owner

@jjasghar commented on GitHub (Aug 1, 2024):

Yeah i'm on a Mac, i should have mentioned that, sorry about that.

I don't think I can pull the binary down, it looks like that the install.sh is linux specific, and the core file is a .zip --> https://ollama.com/download/Ollama-darwin.zip

<!-- gh-comment-id:2263604445 --> @jjasghar commented on GitHub (Aug 1, 2024): Yeah i'm on a Mac, i should have mentioned that, sorry about that. I don't think I can pull the binary down, it looks like that the `install.sh` is linux specific, and the core file is a `.zip` --> https://ollama.com/download/Ollama-darwin.zip
Author
Owner

@rick-github commented on GitHub (Aug 1, 2024):

I imagine that it would be possible to install ollama from the zip file to get the client, and just disable the server so that it doesn't clash with the dockerized ollama.

<!-- gh-comment-id:2263613602 --> @rick-github commented on GitHub (Aug 1, 2024): I imagine that it would be possible to install ollama from the zip file to get the client, and just disable the server so that it doesn't clash with the dockerized ollama.
Author
Owner

@jjasghar commented on GitHub (Aug 1, 2024):

Ok, it seems https://www.vim.org/scripts/script.php?script_id=302 plugin "fixes" it, so when I run

r !ollama run granite-code:20b show me a python fuction that does fizzbuzz

It outputs more or less correctly. The formatting is still all wrong, but it least I can actually read the output now.

⠙ ⠹ ⠸                                                                                    Sure! Here                                                                               's a Python function that                                                                 implements the FizzBu                                                                   zz game logic:

def fizzbuzz(                                                                            n):
    if n % 3                                                                              == 0 and n                                                                              % 5 == 0                                                                                 :
        return "Fizz                                                                     Buzz"
    elif n % 3                                                                            == 0:
        return "Fizz                                                                     "
    elif n % 5                                                                            == 0:
        return "Buzz                                                                     "
    else:
        return str(n                                                                     )

This function takes an                                                                    integer `n` as                                                                          input and returns a string                                                                representing the FizzBu                                                                 zz value for that num                                                                    ber. If `n`                                                                               is divisible by both                                                                     3 and 5,                                                                                 it returns "Fizz                                                                        Buzz". If it                                                                             's only divisible by                                                                      3, it returns "                                                                         Fizz", and if                                                                             it's only divisible                                                                      by 5, it                                                                                returns "Buzz". Oth                                                                      erwise, it simply returns                                                                 the string representation of                                                             `n`.

<!-- gh-comment-id:2263628260 --> @jjasghar commented on GitHub (Aug 1, 2024): Ok, it seems https://www.vim.org/scripts/script.php?script_id=302 plugin "fixes" it, so when I run ```vim r !ollama run granite-code:20b show me a python fuction that does fizzbuzz ``` It outputs _more_ or less correctly. The formatting is still all wrong, but it least I can actually read the output now. ```text ⠙ ⠹ ⠸ Sure! Here 's a Python function that implements the FizzBu zz game logic: def fizzbuzz( n): if n % 3 == 0 and n % 5 == 0 : return "Fizz Buzz" elif n % 3 == 0: return "Fizz " elif n % 5 == 0: return "Buzz " else: return str(n ) This function takes an integer `n` as input and returns a string representing the FizzBu zz value for that num ber. If `n` is divisible by both 3 and 5, it returns "Fizz Buzz". If it 's only divisible by 3, it returns " Fizz", and if it's only divisible by 5, it returns "Buzz". Oth erwise, it simply returns the string representation of `n`. ```
Author
Owner

@gabe-l-hart commented on GitHub (Aug 1, 2024):

I'm able to repro on a fresh build of main:

./ollama run granite-code:20b show me a python fuction that does fizzbuzz 2>&1 | cat -v
^[[?25l?M-^Y ^[[?25h^[[?25l^[[2K^[[1G⠹ ^[[?25h^[[?25l^[[2K^[[1G⠸ ^[[?25h^[[?25l^[[2K^[[1G⠼ ^[[?25h^[[?25l^[[2K^[[1G⠴ ^[[?25h^[[?25l^[[2K^[[1G⠦ ^[[?25h^[[?25l^[[2K^[[1G⠦ ^[[?25h^[[?25l^[[2K^[[1G?M-^G ^[[?25h^[[?25l^[[2K^[[1G?M-^O ^[[?25h^[[?25l^[[2K^[[1G?M-^O ^[[?25h^[[?25l^[[2K^[[1G?M-^Y ^[[?25h^[[?25l^[[2K^[[1G⠹ ^[[?25h^[[?25l^[[2K^[[1G⠸ ^[[?25h^[[?25l^[[2K^[[1G⠼ ^[[?25h^[[?25l^[[2K^[[1G⠴ ^[[?25h^[[?25l^[[2K^[[1G⠦ ^[[?25h^[[?25l^[[2K^[[1G⠦ ^[[?25h^[[?25l^[[2K^[[1G?M-^G ^[[?25h^[[?25l^[[2K^[[1G?M-^O ^[[?25h^[[?25l^[[2K^[[1G?M-^K ^[[?25h^[[?25l^[[2K^[[1G?M-^Y ^[[?25h^[[?25l^[[2K^[[1G⠹ ^[[?25h^[[?25l^[[2K^[[1G⠹ ^[[?25h^[[?25l^[[2K^[[1G⠼ ^[[?25h^[[?25l^[[2K^[[1G⠼ ^[[?25h^[[?25l^[[2K^[[1G⠴ ^[[?25h^[[?25l^[[2K^[[1G⠦ ^[[?25h^[[?25l^[[2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 ^[[?25h^[[?25l^[[2K^[[1G⠦ ^[[?25h^[[?25l^[[2K^[[1G⠧ ^[[?25h^[[?25l^[[2K^[[1G?M-^G ^[[?25h^[[?25l^[[2K^[[1G?M-^O ^[[?25h^[[?25l^[[2K^[[1G?M-^O ^[[?25h^[[?25l^[[2K^[[1G?M-^Y ^[[?25h^[[?25l^[[2K^[[1G⠹ ^[[?25h^[[?25l^[[2K^[[1G⠸ ^[[?25h^[[?25l^[[2K^[[1G⠼ ^[[?25h^[[?25l^[[2K^[[1G⠴ ^[[?25h^[[?25l^[[2K^[[1G⠦ ^[[?25h^[[?25l^[[2K^[[1G⠧ ^[[?25h^[[?25l^[[2K^[[1G?M-^G ^[[?25h^[[?25l^[[2K^[[1G?M-^O ^[[?25h^[[?25l^[[2K^[[1G?M-^K ^[[?25h^[[?25l^[[2K^[[1G?M-^K ^[[?25h^[[?25l^[[2K^[[1G⠹ ^[[?25h^[[?25l^[[2K^[[1G⠹ ^[[?25h^[[?25l^[[2K^[[1G⠼ ^[[?25h^[[?25l^[[2K^[[1G⠴ ^[[?25h^[[?25l^[[2K^[[1G⠦ ^[[?25h^[[?25l^[[2K^[[1G⠦ ^[[?25h^[[?25l^[[2K^[[1G?M-^G ^[[?25h^[[?25l^[[2K^[[1G?M-^O ^[[?25h^[[?25l^[[2K^[[1G?M-^K ^[[?25h^[[?25l^[[2K^[[1G?M-^Y ^[[?25h^[[?25l^[[2K^[[1G⠹ ^[[?25h^[[?25l^[[2K^[[1G⠸ ^[[?25h^[[?25l^[[2K^[[1G⠼ ^[[?25h^[[?25l^[[2K^[[1G⠴ ^[[?25h^[[?25l^[[?25l^[[2K^[[1G^[[?25h^[[2K^[[1G^[[?25hHere^[[?25l^[[?25h's^[[?25l^[[?25h an^[[?25l^[[?25h example^[[?25l^[[?25h of^[[?25l^[[?25h a^[[?25l^[[?25h Python^[[?25l^[[?25h function^[[?25l^[[?25h that^[[?25l^[[?25h implements^[[?25l^[[?25h the^[[?25l^[[?25h F^[[?25l^[[?25hizz^[[?25l^[[?25hBu^[[?25l^[[?25hzz^[[?25l^[[?25h algorithm^[[?25l^[[?25h:^[[?25l^[[?25h
^[[?25l^[[?25h
^[[?25l^[[?25h```^[[?25l^[[?25hpython^[[?25l^[[?25h
^[[?25l^[[?25hdef^[[?25l^[[?25h f^[[?25l^[[?25hizz^[[?25l^[[?25hbuzz^[[?25l^[[?25h(^[[?25l^[[?25hn^[[?25l^[[?25h):^[[?25l^[[?25h
   ^[[?25l^[[?25h for^[[?25l^[[?25h i^[[?25l^[[?25h in^[[?25l^[[?25h range^[[?25l^[[?25h(^[[?25l^[[?25h1^[[?25l^[[?25h,^[[?25l^[[?25h n^[[?25l^[[?25h+^[[?25l^[[?25h1^[[?25l^[[?25h):^[[?25l^[[?25h
       ^[[?25l^[[?25h if^[[?25l^[[?25h i^[[?25l^[[?25h %^[[?25l^[[?25h ^[[?25l^[[?25h3^[[?25l^[[?25h ==^[[?25l^[[?25h ^[[?25l^[[?25h0^[[?25l^[[?25h and^[[?25l^[[?25h i^[[?25l^[[?25h %^[[?25l^[[?25h ^[[?25l^[[?25h5^[[?25l^[[?25h ==^[[?25l^[[?25h ^[[?25l^[[?25h0^[[?25l^[[?25h:^[[?25l^[[?25h
           ^[[?25l^[[?25h print^[[?25l^[[?25h("^[[?25l^[[?25hF^[[?25l^[[?25hizz^[[?25l^[[?25hBu^[[?25l^[[?25hzz^[[?25l^[[?25h")^[[?25l^[[?25h
       ^[[?25l^[[?25h elif^[[?25l^[[?25h i^[[?25l^[[?25h %^[[?25l^[[?25h ^[[?25l^[[?25h3^[[?25l^[[?25h ==^[[?25l^[[?25h ^[[?25l^[[?25h0^[[?25l^[[?25h:^[[?25l^[[?25h
           ^[[?25l^[[?25h print^[[?25l^[[?25h("^[[?25l^[[?25hF^[[?25l^[[?25hizz^[[?25l^[[?25h")^[[?25l^[[?25h
       ^[[?25l^[[?25h elif^[[?25l^[[?25h i^[[?25l^[[?25h %^[[?25l^[[?25h ^[[?25l^[[?25h5^[[?25l^[[?25h ==^[[?25l^[[?25h ^[[?25l^[[?25h0^[[?25l^[[?25h:^[[?25l^[[?25h
           ^[[?25l^[[?25h print^[[?25l^[[?25h("^[[?25l^[[?25hBu^[[?25l^[[?25hzz^[[?25l^[[?25h")^[[?25l^[[?25h
       ^[[?25l^[[?25h else^[[?25l^[[?25h:^[[?25l^[[?25h
           ^[[?25l^[[?25h print^[[?25l^[[?25h(^[[?25l^[[?25hi^[[?25l^[[?25h)^[[?25l^[[?25h
^[[?25l^[[?25h```^[[?25l^[[?25h
^[[?25l^[[?25h
^[[?25l^[[?25hThe^[[?25l^[[?25h F^[[?25l^[[?25hizz^[[?25l^[[?25hBu^[[?25l^[[?25hzz^[[?25l^[[?25h algorithm^[[?25l^[[?25h is^[[?25l^[[?25h a^[[?25l^[[?25h common^[[?25l^[[?25h programming^[[?25l^[[?25h inter^[[?25l^[[?25hview^[[?25l^[[?25h question^[[?25l^[[?25h that^[[?25l^[[?25h involves^[[?25l^[[?25h printing^[[?25l^[[?25h out^[[?25l^[[?25h numbers^[[?25l^[[?25h from^[[?25l^[[?25h ^[[?25l^[[?25h1^[[?25l^[[?25h to^[[?25l^[[?25h `^[[?25l^[[?25hn^[[?25l^[[?25h`,^[[?25l^[[?25h but^[[?25l^[[?25h replacing^[[?25l^[[?25h multip^[[?25l^[[?25hles^[[?25l^[[?25h of^[[?25l^[[?25h ^[[?25l^[[?25h3^[[?25l^[[?25h with^[[?25l^[[?25h "^[[?25l^[[?25hF^[[?25l^[[?25hizz^[[?25l^[[?25h",^[[?25l^[[?25h multip^[[?25l^[[?25hles^[[?25l^[[?25h of^[[?25l^[[?25h ^[[?25l^[[?25h5^[[?25l^[[?25h with^[[?25l^[[?25h "^[[?25l^[[?25hBu^[[?25l^[[?25hzz^[[?25l^[[?25h",^[[?25l^[[?25h and^[[?25l^[[?25h multip^[[?25l^[[?25hles^[[?25l^[[?25h of^[[?25l^[[?25h both^[[?25l^[[?25h ^[[?25l^[[?25h3^[[?25l^[[?25h and^[[?25l^[[?25h ^[[?25l^[[?25h5^[[?25l^[[?25h with^[[?25l^[[?25h "^[[?25l^[[?25hF^[[?25l^[[?25hizz^[[?25l^[[?25hBu^[[?25l^[[?25hzz^[[?25l^[[?25h".^[[?25l^[[?25h This^[[?25l^[[?25h function^[[?25l^[[?25h takes^[[?25l^[[?25h an^[[?25l^[[?25h integer^[[?25l^[[?25h `^[[?25l^[[?25hn^[[?25l^[[?25h`^[[?25l^[[?25h as^[[?25l^[[?25h input^[[?25l^[[?25h and^[[?25l^[[?25h uses^[[?25l^[[?25h a^[[?25l^[[?25h loop^[[?25l^[[?25h to^[[?25l^[[?25h iterate^[[?25l^[[?25h over^[[?25l^[[?25h the^[[?25l^[[?25h numbers^[[?25l^[[?25h from^[[?25l^[[?25h ^[[?25l^[[?25h1^[[?25l^[[?25h to^[[?25l^[[?25h `^[[?25l^[[?25hn^[[?25l^[[?25h`.^[[?25l^[[?25h For^[[?25l^[[?25h each^[[?25l^[[?25h number^[[?25l^[[?25h,^[[?25l^[[?25h it^[[?25l^[[?25h checks^[[?25l^[[?25h if^[[?25l^[[?25h it^[[?25l^[[?25h is^[[?25l^[[?25h div^[[?25l^[[?25hisible^[[?25l^[[?25h by^[[?25l^[[?25h both^[[?25l^[[?25h ^[[?25l^[[?25h3^[[?25l^[[?25h and^[[?25l^[[?25h ^[[?25l^[[?25h5^[[?25l^[[?25h using^[[?25l^[[?25h the^[[?25l^[[?25h modulo^[[?25l^[[?25h operator^[[?25l^[[?25h `%^[[?25l^[[?25h`.^[[?25l^[[?25h If^[[?25l^[[?25h so^[[?25l^[[?25h,^[[?25l^[[?25h it^[[?25l^[[?25h prints^[[?25l^[[?25h "^[[?25l^[[?25hF^[[?25l^[[?25hizz^[[?25l^[[?25hBu^[[?25l^[[?25hzz^[[?25l^[[?25h".^[[?25l^[[?25h If^[[?25l^[[?25h not^[[?25l^[[?25h,^[[?25l^[[?25h it^[[?25l^[[?25h checks^[[?25l^[[?25h if^[[?25l^[[?25h it^[[?25l^[[?25h is^[[?25l^[[?25h div^[[?25l^[[?25hisible^[[?25l^[[?25h by^[[?25l^[[?25h ^[[?25l^[[?25h3^[[?25l^[[?25h or^[[?25l^[[?25h ^[[?25l^[[?25h5^[[?25l^[[?25h individually^[[?25l^[[?25h and^[[?25l^[[?25h prints^[[?25l^[[?25h the^[[?25l^[[?25h appropriate^[[?25l^[[?25h word^[[?25l^[[?25h.^[[?25l^[[?25h If^[[?25l^[[?25h none^[[?25l^[[?25h of^[[?25l^[[?25h these^[[?25l^[[?25h conditions^[[?25l^[[?25h are^[[?25l^[[?25h met^[[?25l^[[?25h,^[[?25l^[[?25h it^[[?25l^[[?25h simply^[[?25l^[[?25h prints^[[?25l^[[?25h the^[[?25l^[[?25h number^[[?25l^[[?25h itself^[[?25l^[[?25h.^[[?25l^[[?25h
<!-- gh-comment-id:2264087177 --> @gabe-l-hart commented on GitHub (Aug 1, 2024): I'm able to repro on a fresh build of `main`: ```sh ./ollama run granite-code:20b show me a python fuction that does fizzbuzz 2>&1 | cat -v ^[[?25l?M-^Y ^[[?25h^[[?25l^[[2K^[[1G⠹ ^[[?25h^[[?25l^[[2K^[[1G⠸ ^[[?25h^[[?25l^[[2K^[[1G⠼ ^[[?25h^[[?25l^[[2K^[[1G⠴ ^[[?25h^[[?25l^[[2K^[[1G⠦ ^[[?25h^[[?25l^[[2K^[[1G⠦ ^[[?25h^[[?25l^[[2K^[[1G?M-^G ^[[?25h^[[?25l^[[2K^[[1G?M-^O ^[[?25h^[[?25l^[[2K^[[1G?M-^O ^[[?25h^[[?25l^[[2K^[[1G?M-^Y ^[[?25h^[[?25l^[[2K^[[1G⠹ ^[[?25h^[[?25l^[[2K^[[1G⠸ ^[[?25h^[[?25l^[[2K^[[1G⠼ ^[[?25h^[[?25l^[[2K^[[1G⠴ ^[[?25h^[[?25l^[[2K^[[1G⠦ ^[[?25h^[[?25l^[[2K^[[1G⠦ ^[[?25h^[[?25l^[[2K^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25h^[[?25l^[[2K^[[1G⠸ ^[[?25h^[[?25l^[[2K^[[1G⠼ ^[[?25h^[[?25l^[[2K^[[1G⠴ ^[[?25h^[[?25l^[[?25l^[[2K^[[1G^[[?25h^[[2K^[[1G^[[?25hHere^[[?25l^[[?25h's^[[?25l^[[?25h an^[[?25l^[[?25h example^[[?25l^[[?25h of^[[?25l^[[?25h a^[[?25l^[[?25h Python^[[?25l^[[?25h function^[[?25l^[[?25h that^[[?25l^[[?25h implements^[[?25l^[[?25h the^[[?25l^[[?25h F^[[?25l^[[?25hizz^[[?25l^[[?25hBu^[[?25l^[[?25hzz^[[?25l^[[?25h algorithm^[[?25l^[[?25h:^[[?25l^[[?25h ^[[?25l^[[?25h ^[[?25l^[[?25h```^[[?25l^[[?25hpython^[[?25l^[[?25h ^[[?25l^[[?25hdef^[[?25l^[[?25h f^[[?25l^[[?25hizz^[[?25l^[[?25hbuzz^[[?25l^[[?25h(^[[?25l^[[?25hn^[[?25l^[[?25h):^[[?25l^[[?25h ^[[?25l^[[?25h for^[[?25l^[[?25h i^[[?25l^[[?25h in^[[?25l^[[?25h range^[[?25l^[[?25h(^[[?25l^[[?25h1^[[?25l^[[?25h,^[[?25l^[[?25h n^[[?25l^[[?25h+^[[?25l^[[?25h1^[[?25l^[[?25h):^[[?25l^[[?25h ^[[?25l^[[?25h if^[[?25l^[[?25h i^[[?25l^[[?25h %^[[?25l^[[?25h ^[[?25l^[[?25h3^[[?25l^[[?25h ==^[[?25l^[[?25h ^[[?25l^[[?25h0^[[?25l^[[?25h and^[[?25l^[[?25h i^[[?25l^[[?25h %^[[?25l^[[?25h ^[[?25l^[[?25h5^[[?25l^[[?25h ==^[[?25l^[[?25h ^[[?25l^[[?25h0^[[?25l^[[?25h:^[[?25l^[[?25h ^[[?25l^[[?25h print^[[?25l^[[?25h("^[[?25l^[[?25hF^[[?25l^[[?25hizz^[[?25l^[[?25hBu^[[?25l^[[?25hzz^[[?25l^[[?25h")^[[?25l^[[?25h ^[[?25l^[[?25h elif^[[?25l^[[?25h i^[[?25l^[[?25h %^[[?25l^[[?25h ^[[?25l^[[?25h3^[[?25l^[[?25h ==^[[?25l^[[?25h ^[[?25l^[[?25h0^[[?25l^[[?25h:^[[?25l^[[?25h ^[[?25l^[[?25h print^[[?25l^[[?25h("^[[?25l^[[?25hF^[[?25l^[[?25hizz^[[?25l^[[?25h")^[[?25l^[[?25h ^[[?25l^[[?25h elif^[[?25l^[[?25h i^[[?25l^[[?25h %^[[?25l^[[?25h ^[[?25l^[[?25h5^[[?25l^[[?25h ==^[[?25l^[[?25h ^[[?25l^[[?25h0^[[?25l^[[?25h:^[[?25l^[[?25h ^[[?25l^[[?25h print^[[?25l^[[?25h("^[[?25l^[[?25hBu^[[?25l^[[?25hzz^[[?25l^[[?25h")^[[?25l^[[?25h ^[[?25l^[[?25h else^[[?25l^[[?25h:^[[?25l^[[?25h ^[[?25l^[[?25h print^[[?25l^[[?25h(^[[?25l^[[?25hi^[[?25l^[[?25h)^[[?25l^[[?25h ^[[?25l^[[?25h```^[[?25l^[[?25h ^[[?25l^[[?25h ^[[?25l^[[?25hThe^[[?25l^[[?25h F^[[?25l^[[?25hizz^[[?25l^[[?25hBu^[[?25l^[[?25hzz^[[?25l^[[?25h algorithm^[[?25l^[[?25h is^[[?25l^[[?25h a^[[?25l^[[?25h common^[[?25l^[[?25h programming^[[?25l^[[?25h inter^[[?25l^[[?25hview^[[?25l^[[?25h question^[[?25l^[[?25h that^[[?25l^[[?25h involves^[[?25l^[[?25h printing^[[?25l^[[?25h out^[[?25l^[[?25h numbers^[[?25l^[[?25h from^[[?25l^[[?25h ^[[?25l^[[?25h1^[[?25l^[[?25h to^[[?25l^[[?25h `^[[?25l^[[?25hn^[[?25l^[[?25h`,^[[?25l^[[?25h but^[[?25l^[[?25h replacing^[[?25l^[[?25h multip^[[?25l^[[?25hles^[[?25l^[[?25h of^[[?25l^[[?25h ^[[?25l^[[?25h3^[[?25l^[[?25h with^[[?25l^[[?25h "^[[?25l^[[?25hF^[[?25l^[[?25hizz^[[?25l^[[?25h",^[[?25l^[[?25h multip^[[?25l^[[?25hles^[[?25l^[[?25h of^[[?25l^[[?25h ^[[?25l^[[?25h5^[[?25l^[[?25h with^[[?25l^[[?25h "^[[?25l^[[?25hBu^[[?25l^[[?25hzz^[[?25l^[[?25h",^[[?25l^[[?25h and^[[?25l^[[?25h multip^[[?25l^[[?25hles^[[?25l^[[?25h of^[[?25l^[[?25h both^[[?25l^[[?25h ^[[?25l^[[?25h3^[[?25l^[[?25h and^[[?25l^[[?25h ^[[?25l^[[?25h5^[[?25l^[[?25h with^[[?25l^[[?25h "^[[?25l^[[?25hF^[[?25l^[[?25hizz^[[?25l^[[?25hBu^[[?25l^[[?25hzz^[[?25l^[[?25h".^[[?25l^[[?25h This^[[?25l^[[?25h function^[[?25l^[[?25h takes^[[?25l^[[?25h an^[[?25l^[[?25h integer^[[?25l^[[?25h `^[[?25l^[[?25hn^[[?25l^[[?25h`^[[?25l^[[?25h as^[[?25l^[[?25h input^[[?25l^[[?25h and^[[?25l^[[?25h uses^[[?25l^[[?25h a^[[?25l^[[?25h loop^[[?25l^[[?25h to^[[?25l^[[?25h iterate^[[?25l^[[?25h over^[[?25l^[[?25h the^[[?25l^[[?25h numbers^[[?25l^[[?25h from^[[?25l^[[?25h ^[[?25l^[[?25h1^[[?25l^[[?25h to^[[?25l^[[?25h `^[[?25l^[[?25hn^[[?25l^[[?25h`.^[[?25l^[[?25h For^[[?25l^[[?25h each^[[?25l^[[?25h number^[[?25l^[[?25h,^[[?25l^[[?25h it^[[?25l^[[?25h checks^[[?25l^[[?25h if^[[?25l^[[?25h it^[[?25l^[[?25h is^[[?25l^[[?25h div^[[?25l^[[?25hisible^[[?25l^[[?25h by^[[?25l^[[?25h both^[[?25l^[[?25h ^[[?25l^[[?25h3^[[?25l^[[?25h and^[[?25l^[[?25h ^[[?25l^[[?25h5^[[?25l^[[?25h using^[[?25l^[[?25h the^[[?25l^[[?25h modulo^[[?25l^[[?25h operator^[[?25l^[[?25h `%^[[?25l^[[?25h`.^[[?25l^[[?25h If^[[?25l^[[?25h so^[[?25l^[[?25h,^[[?25l^[[?25h it^[[?25l^[[?25h prints^[[?25l^[[?25h "^[[?25l^[[?25hF^[[?25l^[[?25hizz^[[?25l^[[?25hBu^[[?25l^[[?25hzz^[[?25l^[[?25h".^[[?25l^[[?25h If^[[?25l^[[?25h not^[[?25l^[[?25h,^[[?25l^[[?25h it^[[?25l^[[?25h checks^[[?25l^[[?25h if^[[?25l^[[?25h it^[[?25l^[[?25h is^[[?25l^[[?25h div^[[?25l^[[?25hisible^[[?25l^[[?25h by^[[?25l^[[?25h ^[[?25l^[[?25h3^[[?25l^[[?25h or^[[?25l^[[?25h ^[[?25l^[[?25h5^[[?25l^[[?25h individually^[[?25l^[[?25h and^[[?25l^[[?25h prints^[[?25l^[[?25h the^[[?25l^[[?25h appropriate^[[?25l^[[?25h word^[[?25l^[[?25h.^[[?25l^[[?25h If^[[?25l^[[?25h none^[[?25l^[[?25h of^[[?25l^[[?25h these^[[?25l^[[?25h conditions^[[?25l^[[?25h are^[[?25l^[[?25h met^[[?25l^[[?25h,^[[?25l^[[?25h it^[[?25l^[[?25h simply^[[?25l^[[?25h prints^[[?25l^[[?25h the^[[?25l^[[?25h number^[[?25l^[[?25h itself^[[?25l^[[?25h.^[[?25l^[[?25h ```
Author
Owner

@gabe-l-hart commented on GitHub (Aug 1, 2024):

I think the issue is the spinny-wheel animation that gets printed to stderr. If I remove the 2>&1, I don't see the control characters when piped to cat -v.

<!-- gh-comment-id:2264089739 --> @gabe-l-hart commented on GitHub (Aug 1, 2024): I think the issue is the spinny-wheel animation that gets printed to `stderr`. If I remove the `2>&1`, I don't see the control characters when piped to `cat -v`.
Author
Owner

@jjasghar commented on GitHub (Aug 1, 2024):

Maybe theres a flag we can add to remove the spinny wheel thing? Just let it sit there and the output for situations like this?

<!-- gh-comment-id:2264097130 --> @jjasghar commented on GitHub (Aug 1, 2024): Maybe theres a flag we can add to remove the spinny wheel thing? Just let it sit there and the output for situations like this?
Author
Owner

@gabe-l-hart commented on GitHub (Aug 1, 2024):

I've got a PR that adds --quiet to the ollama run command and disables the control characters: https://github.com/ollama/ollama/pull/6130

<!-- gh-comment-id:2264120479 --> @gabe-l-hart commented on GitHub (Aug 1, 2024): I've got a PR that adds `--quiet` to the `ollama run` command and disables the control characters: https://github.com/ollama/ollama/pull/6130
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#3824