Skip to content

How to turn off display of think process tokens when using qwen models with ollama #1439

Closed

Description

@cainiaocome

Background:

  • the model is qwen3:8b, running on ollama
  • I use lazyvim to managed the installation and CopilotChat configured through lazyvim.

Below is a chat session asking about a hello-world script written in Python, as you can see the think process tokens(wrapped between <think>...</think> it seems) are in the output as well. Is there a way to turn them off as I only need the output after that. Thanks!

## User (ef372c4b-67a0-4ade-a86d-638e955affe5)───

explain the code

## Copilot (99a3582b-6b58-4ae5-abdc-a5002940fab1)───

<think>
Okay, let's look at the code the user provided. The file is t.py, and the code starts with the shebang line #!/usr/bin/env python, which is correct for making the script executable. Then there's a blank line, followed by a print statement that outputs "hello, world". 

Next, there's an if __name__ == "__main__": block, but inside it, there's just a pass statement. That means when the script is run directly, nothing happens beyond the print statement. The user wants an explanation of this code.

So, the code is a simple Python script. The shebang line allows it to be run as a standalone script. The print statement is straightforward. The if __name__ block is typical for Python scripts to define what happens when the file is executed. However, in this case, the block doesn't contain any code except pass, which does nothing. 

The user might be confused about why the if __name__ block is present if it's not doing anything. They might also want to know how to run the script or what each part does. I should explain each part clearly, pointing out that the script will print "hello, world" when run, but the main block is empty. Maybe suggest adding code inside the if __name__ block to perform actions when the script is executed. Also, mention that the shebang line is necessary for making the script executable, and that the print statement is the main output. I should keep the explanation concise but cover all parts of the code.
</think>

The code is a minimal Python script with these components:

1. Shebang line `#!/usr/bin/env python` - allows execution as a standalone script
2. Blank line (no functional purpose)
3. `print("hello, world")` - outputs the classic greeting
4. `if __name__ == "__main__":` block with `pass` - empty execution block for potential future code

When run, it will output:
\```
hello, world
\```

The script is functionally equivalent to:
\```python
print("hello, world")
\```

The empty `if __name__` block is a common pattern for adding script-specific logic when the file is executed directly.

## User (662f7844-b09a-492b-9dba-c9a0f7716771)───


Activity

  1. deathbeam commented on Sep 25, 2025

    @deathbeam
    Collaborator

    You can technically override response.content in callback and then it will be replaced in chat after response is received. obviously the downside of this is that the thinking part wont be sent back to LLM either in the history

  2. deathbeam commented on Sep 27, 2025

    @deathbeam
    Collaborator

    Moving this to discussions as its not really an issue

  3. locked and limited conversation to collaborators on Sep 27, 2025
  4. converted this issue into a discussion #1446 on Sep 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions