-
Notifications
You must be signed in to change notification settings - Fork 2.6k
initial thinking support for claude #15092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@eneufeld This is currently under work, right? So no review needed right now? |
exactly, no review needed, a test would be nice to confirm we go into the right direction. Then we can discuss next steps what needs to be added to make this final |
333d23b
to
3d50d23
Compare
Currently, our application has fragmented tracking of the LLM communications: - Chat model doesn't track all LLM messages (e.g. system message) or multiple LLM requests per user response - Chat agents must manually record LLM communications via `CommunicationRecordingService` - Tool calls are tracked in the chat model in content parts, which are rather UI focused, but tool calls missing in the `CommunicationRecordingService` This fragmentation means we lack a single source of truth for chat session information. This PR centralizes all LLM communication tracking in the chat model by: 1. Introducing a new `ChatLanguageModelService` that encapsulates LLM request tracking 2. Moving related code from the abstract chat agent to this new service 3. Feeding the `CommunicationRecordingService` via a simple listener on the chat model - Complete tracking of all LLM requests, responses, and tool calls in one place - Simplified interface for chat agents to interact with LLMs - Improved data structure to capture tool calls and LLM messages in the History View (with minor UI enhancements) Contributed on behalf of STMicroelectronics
* Move default request settings from individual models to frontend LanguageModelService * Enhance RequestSettingsSchema with model/provider/agent scoping * Add client-side settings for tool calls and thinking messages
- Updated the Anthropic SDK from v0.32.1 to v0.39.0 - Added support for thinking messages in the language model interface - Added a ThinkingChatResponseContent implementation - Added proper handling for Claude's thinking feature in the Anthropic language model - Added a TextPartRenderer to display thinking content - Various interface updates to support thinking messages throughout the code
1e2270a
to
f33edbb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a first look at the PR. To enable work on the PR I leave this intermediate review and will come with a full review later.
Overall it looks very good. However I did not yet
- actually run the code
- looked into detail on how the new request settings determination works
packages/ai-chat-ui/src/browser/chat-response-renderer/thinking-part-renderer.tsx
Outdated
Show resolved
Hide resolved
packages/ai-chat-ui/src/browser/chat-view-widget-toolbar-contribution.tsx
Outdated
Show resolved
Hide resolved
packages/ai-hugging-face/src/node/huggingface-language-model.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a closer look at the PR. You can find my comments inline.
I tested the thinking support via the request settings in the preferences, as well as via the chat session requests. Both worked for me 👍
Based on my last review you adapted the handling of empty message for the HuggingFace language model, however we should handle this the same way for all language models. So we should either revert that change or apply it to all of them.
packages/ai-chat-ui/src/browser/chat-response-renderer/thinking-part-renderer.tsx
Outdated
Show resolved
Hide resolved
packages/ai-chat-ui/src/browser/chat-response-renderer/thinking-part-renderer.tsx
Show resolved
Hide resolved
export const EDIT_SESSION_SETTINGS = Command.toLocalizedCommand({ | ||
id: 'chat:widget:session-settings', | ||
category: CHAT_CATEGORY, | ||
iconClass: codicon('bracket') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added to the ai epic
packages/ai-core/src/browser/frontend-language-model-service.ts
Outdated
Show resolved
Hide resolved
packages/ai-core/src/browser/frontend-language-model-service.ts
Outdated
Show resolved
Hide resolved
packages/ai-core/src/browser/frontend-language-model-service.ts
Outdated
Show resolved
Hide resolved
packages/ai-core/src/browser/frontend-language-model-service.ts
Outdated
Show resolved
Hide resolved
<div className='theia-thinking'> | ||
<details> | ||
<summary>{nls.localize('theia/ai/chat-ui/thinking-part-renderer/thinking', 'Thinking')}</summary> | ||
<pre>{response.content}</pre> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer this to be regular text or markdown rendering. Wrapping in <pre>
does not do any wrapping, making it painful to inspect for longer lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added text wrapping for the pre element, maybe this is enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the rendering can be further improved, but this can be done in a follow up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me! Great work ❤️
I only have minor comments left (the unresolved ones). Feel free to tackle them here or to create follow up issue(s).
@eneufeld actually this is a breaking change. So we should at adapt the changelog and at least indicate the changes in the request API |
What it does
How to test
Add this or similar to your settings.json:
This will enable the thinking mode on the Architect.
As you can provide chat settings you can just add the requestSettings part to your chat for any agent as long as it uses sonnet-3.7
Follow-ups
Breaking changes
Attribution
Review checklist
Reminder for reviewers