-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support llm tool call streaming and ui, more mcp tools
- Loading branch information
Showing
22 changed files
with
638 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,4 +98,5 @@ tools/workspace | |
# jupyter | ||
.ipynb_checkpoints | ||
|
||
*.tsbuildinfo | ||
*.tsbuildinfo | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,9 @@ | |
"url": "[email protected]:opensumi/core.git" | ||
}, | ||
"dependencies": { | ||
"@ai-sdk/anthropic": "^1.0.9", | ||
"@anthropic-ai/sdk": "^0.32.1", | ||
"@ai-sdk/anthropic": "^1.1.6", | ||
"@ai-sdk/deepseek": "^0.1.8", | ||
"@anthropic-ai/sdk": "^0.36.3", | ||
"@modelcontextprotocol/sdk": "^1.3.1", | ||
"@opensumi/ide-components": "workspace:*", | ||
"@opensumi/ide-core-common": "workspace:*", | ||
|
@@ -41,7 +42,7 @@ | |
"@opensumi/ide-utils": "workspace:*", | ||
"@opensumi/ide-workspace": "workspace:*", | ||
"@xterm/xterm": "5.5.0", | ||
"ai": "^4.0.38", | ||
"ai": "^4.1.21", | ||
"ansi-regex": "^2.0.0", | ||
"dom-align": "^1.7.0", | ||
"openai": "^4.55.7", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
packages/ai-native/src/browser/components/ChatToolRender.module.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
.chat-tool-render { | ||
margin: 8px 0; | ||
border: 1px solid #363636; | ||
border-radius: 6px; | ||
overflow: hidden; | ||
|
||
.tool-header { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
padding: 8px 12px; | ||
background-color: #2D2D2D; | ||
cursor: pointer; | ||
user-select: none; | ||
|
||
&:hover { | ||
background-color: #363636; | ||
} | ||
} | ||
|
||
.tool-name { | ||
display: flex; | ||
align-items: center; | ||
font-weight: 500; | ||
color: #CCCCCC; | ||
} | ||
|
||
.expand-icon { | ||
display: inline-block; | ||
margin-right: 8px; | ||
transition: transform 0.2s; | ||
color: #888888; | ||
|
||
&.expanded { | ||
transform: rotate(90deg); | ||
} | ||
} | ||
|
||
.tool-state { | ||
display: flex; | ||
align-items: center; | ||
font-size: 12px; | ||
color: #888888; | ||
} | ||
|
||
.state-icon { | ||
display: flex; | ||
align-items: center; | ||
margin-right: 6px; | ||
} | ||
|
||
.loading-icon { | ||
width: 12px; | ||
height: 12px; | ||
} | ||
|
||
.state-label { | ||
margin-left: 4px; | ||
} | ||
|
||
.tool-content { | ||
max-height: 0; | ||
overflow: hidden; | ||
transition: max-height 0.3s ease-out; | ||
background-color: #1E1E1E; | ||
|
||
&.expanded { | ||
max-height: 1000px; | ||
} | ||
} | ||
|
||
.tool-arguments, | ||
.tool-result { | ||
padding: 12px; | ||
} | ||
|
||
.section-label { | ||
font-size: 12px; | ||
color: #888888; | ||
margin-bottom: 8px; | ||
} | ||
|
||
.tool-result { | ||
border-top: 1px solid #363636; | ||
} | ||
} |
86 changes: 67 additions & 19 deletions
86
packages/ai-native/src/browser/components/ChatToolRender.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,77 @@ | ||
import React from 'react'; | ||
import cls from 'classnames'; | ||
import React, { useState } from 'react'; | ||
|
||
import { Icon } from '@opensumi/ide-core-browser/lib/components'; | ||
import { Loading } from '@opensumi/ide-core-browser/lib/components/ai-native'; | ||
import { IChatToolContent, uuid } from '@opensumi/ide-core-common'; | ||
|
||
import { CodeEditorWithHighlight } from './ChatEditor'; | ||
import styles from './ChatToolRender.module.less'; | ||
|
||
export const ChatToolRender = (props: { value: IChatToolContent['content'] }) => { | ||
const { value } = props; | ||
console.log('🚀 ~ ChatToolRender ~ toolCall:', value); | ||
const { value } = props; | ||
const [isExpanded, setIsExpanded] = useState(false); | ||
|
||
if (!value || !value.function || !value.id) { | ||
return null; | ||
if (!value || !value.function || !value.id) { | ||
return null; | ||
} | ||
|
||
const getStateInfo = (state?: string): { label: string; icon: React.ReactNode } => { | ||
switch (state) { | ||
case 'streaming-start': | ||
case 'streaming': | ||
return { label: 'Generating', icon: <Loading /> }; | ||
case 'complete': | ||
return { label: 'Complete', icon: <Icon iconClass="codicon codicon-check" /> }; | ||
case 'result': | ||
return { label: 'Result Ready', icon: <Icon iconClass="codicon codicon-check-all" /> }; | ||
default: | ||
return { label: state || 'Unknown', icon: <Icon iconClass="codicon codicon-question" /> }; | ||
} | ||
}; | ||
|
||
const toggleExpand = () => { | ||
setIsExpanded(!isExpanded); | ||
}; | ||
|
||
const stateInfo = getStateInfo(value.state); | ||
|
||
return <div> | ||
<span>Using Tool: </span> | ||
<span>{value?.function?.name}</span> | ||
<br /> | ||
<span></span> | ||
{ | ||
value?.function?.arguments && | ||
(<CodeEditorWithHighlight | ||
input={value?.function?.arguments} | ||
language={'json'} | ||
relationId={uuid(4)} | ||
/>) | ||
} | ||
</div>; | ||
return ( | ||
<div className={styles['chat-tool-render']}> | ||
<div className={styles['tool-header']} onClick={toggleExpand}> | ||
<div className={styles['tool-name']}> | ||
<span className={cls(styles['expand-icon'], { [styles.expanded]: isExpanded })}>▶</span> | ||
{value?.function?.name} | ||
</div> | ||
{value.state && ( | ||
<div className={styles['tool-state']}> | ||
<span className={styles['state-icon']}>{stateInfo.icon}</span> | ||
<span className={styles['state-label']}>{stateInfo.label}</span> | ||
</div> | ||
)} | ||
</div> | ||
<div className={cls(styles['tool-content'], { [styles.expanded]: isExpanded })}> | ||
{value?.function?.arguments && ( | ||
<div className={styles['tool-arguments']}> | ||
<div className={styles['section-label']}>Arguments</div> | ||
<CodeEditorWithHighlight | ||
input={value?.function?.arguments} | ||
language={'json'} | ||
relationId={uuid(4)} | ||
/> | ||
</div> | ||
)} | ||
{value?.result && ( | ||
<div className={styles['tool-result']}> | ||
<div className={styles['section-label']}>Result</div> | ||
<CodeEditorWithHighlight | ||
input={value.result} | ||
language={'json'} | ||
relationId={uuid(4)} | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
6d94523
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.
🎉 Next publish successful!
3.7.1-next-1739175521.0