Skip to content

Conversation

@kwsantiago
Copy link
Contributor

Closes #42

Summary

Adds display of intermediate thinking steps from models that support it (o1, Claude 3.5 Sonnet, etc.) to improve transparency in AI responses.

Changes

  • Added thinking parser (utils/thinkingParser.ts) - Detects thinking-capable models and extracts <thinking> content
  • Added thinking UI (components/ui/ThinkingSection.tsx) - Collapsible display with copy functionality
  • Integrated into chat (components/chat/ChatMessages.tsx) - Shows thinking sections for assistant messages
  • Enhanced streaming (utils/apiUtils.ts) - Extracts thinking during response streaming

Features

  • Parse thinking content from model responses
  • Show "thinking..." indicator during processing
  • Collapsible thinking display with brain icon
  • Copy thinking text functionality
  • Provider compatibility (Anthropic, OpenAI)
  • Graceful degradation for non-thinking models

Testing

Tested with thinking-capable model selection and response streaming. Thinking content appears in collapsible sections, preserves in conversation history, and degrades gracefully for regular models.

@vercel
Copy link

vercel bot commented Aug 2, 2025

@kwsantiago is attempting to deploy a commit to the evanyang's Team Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@sh1ftred sh1ftred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works well for OpenAI and Anthropic API streaming, but doesn't work for OpenRouter as they output reasoning is a separate keyword {'reasoning': 'reasons'}.

Merging this as it's still useful for us as it has thinking UI and the parser.
I'm modifying the UI to work for OpenRouter.

I suppose this also doesn't work for displaying the stream for thinking as you don't update UI with accumulatedThinking. Will add that feature as well.

Thanks for the PR :). Really appreciate it.

@kwsantiago
Copy link
Contributor Author

Awesome, glad it's of value @sh1ftred . If you'd like me to work on a follow up PR or any other related help, would love to as I think Routstr is a great idea and want to contribute!

@sh1ftred sh1ftred merged commit 7f55232 into Routstr:main Aug 7, 2025
1 check failed
@sh1ftred
Copy link
Contributor

sh1ftred commented Aug 7, 2025

Hey @kwsantiago, would love it if you can work on #48. It should be similar to how cashu.me works.

If not, you can pick any issue from the TODO section in this view: Freedom AI Tech (view)

@kwsantiago kwsantiago deleted the kwsantiago/42-show-thinking-text branch August 8, 2025 00:32
@kwsantiago
Copy link
Contributor Author

@sh1ftred 48 sounds great, will do! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show thinking text for thinking models

2 participants