rig icon indicating copy to clipboard operation
rig copied to clipboard

feat: improving extractor for reasoning models

Open mtnqln opened this issue 8 months ago • 5 comments

Feature Request

When using the rig extractor module with open-weight reasoning models like Qwen or Deepseek (running via Ollama), the extractor fails to deserialize the LLM responses due to reasoning traces present in the raw output (e.g., ... blocks).

Motivation

I'm using rig with Ollama to build some cool stuff at @nudibranches-tech 🌊 and ran into this issue.

Proposal

We could add a few lines to strip reasoning traces from the raw response when using reasoning-style models. I'm happy to contribute a patch for this.

mtnqln avatar May 05 '25 13:05 mtnqln

Great issue! Most reasoning models pass reasoning tokens thru an extra response parameter but I'm surprised that Ollama isn't setup like this 😅

0xMochan avatar May 05 '25 16:05 0xMochan

I think I could provide the solution for this. Can you assign me to this issue ? I will open a PR.

mtnqln avatar May 14 '25 15:05 mtnqln

Hey @mtnqln - if you're still interested in this I've assigned you the ticket. If you're not interested anymore (understandable as it's been a while since the issue was originally opened), let us know.

joshua-mo-143 avatar Jun 08 '25 16:06 joshua-mo-143

Hey, I'm still interested, but here's the thing: the initial solution I came up with was mostly based on using regex to strip out the reasoning part inside the think tags from the raw response. Now, I believe Ollama supports reasoning separation via its parameters, so my solution doesn't make much sense anymore. That said, I'm happy to help with adding reasoning support to the Ollama agent struct. I saw that you've already started working on it, and I'm willing to contribute to the reasoning part—just let me know if you need help. I might need a bit of time, though, since I'm not an expert on this crate.

mtnqln avatar Jun 18 '25 09:06 mtnqln