[Python] How to remove the <think> tag in reasoning model DeepSeek responses

Discussão em 'Python' iniciado por Stack, Maio 25, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using deepseek llm for my AI app, the responses will include its thinking process.

    It looks something like this: [​IMG]

    the code generate the response :

    # Generate a new response if last message is not from assistant
    if st.session_state.messages[-1]["role"] != "assistant":
    with st.chat_message("assistant"):
    with st.spinner("Thinking..."):
    response = ask_question(qa, prompt)
    print(response.content)
    st.markdown(response.content)
    message = {"role": "assistant", "content": response.content}
    st.session_state.messages.append(message)


    The responses of the AI assistant has content in tags.

    The actual answer is provided after the tags

    do you have any idea please how to remove the think tag please ?

    Continue reading...

Compartilhe esta Página