Feature/OpenAI Response API (#5014)

* - Added support for built-in OpenAI tools including web search, code interpreter, and image generation.
- Enhanced file handling by extracting artifacts and file annotations from response metadata.
- Implemented download functionality for file annotations in the UI.
- Updated chat history management to include additional kwargs for artifacts, file annotations, and used tools.
- Improved UI components to display used tools and file annotations effectively.

* remove redundant currentContainerId

* update comment
This commit is contained in:
Henry Heng
2025-08-07 17:59:05 +01:00
committed by GitHub
parent 3187377c61
commit b608219642
7 changed files with 860 additions and 14 deletions
@@ -21,7 +21,10 @@ import {
IconTrash,
IconInfoCircle,
IconLoader,
IconAlertCircleFilled
IconAlertCircleFilled,
IconCode,
IconWorldWww,
IconPhoto
} from '@tabler/icons-react'
import StopCircleIcon from '@mui/icons-material/StopCircle'
import CancelIcon from '@mui/icons-material/Cancel'
@@ -126,6 +129,19 @@ const AgentFlowNode = ({ data }) => {
return <foundIcon.icon size={24} color={'white'} />
}
const getBuiltInOpenAIToolIcon = (toolName) => {
switch (toolName) {
case 'web_search_preview':
return <IconWorldWww size={14} color={'white'} />
case 'code_interpreter':
return <IconCode size={14} color={'white'} />
case 'image_generation':
return <IconPhoto size={14} color={'white'} />
default:
return null
}
}
useEffect(() => {
if (ref.current) {
setTimeout(() => {
@@ -407,7 +423,17 @@ const AgentFlowNode = ({ data }) => {
: [],
toolProperty: ['selectedTool', 'toolAgentflowSelectedTool']
},
{ tools: data.inputs?.agentKnowledgeVSEmbeddings, toolProperty: ['vectorStore', 'embeddingModel'] }
{ tools: data.inputs?.agentKnowledgeVSEmbeddings, toolProperty: ['vectorStore', 'embeddingModel'] },
{
tools: data.inputs?.agentToolsBuiltInOpenAI
? (typeof data.inputs.agentToolsBuiltInOpenAI === 'string'
? JSON.parse(data.inputs.agentToolsBuiltInOpenAI)
: data.inputs.agentToolsBuiltInOpenAI
).map((tool) => ({ builtInTool: tool }))
: [],
toolProperty: 'builtInTool',
isBuiltInOpenAI: true
}
]
// Filter out undefined tools and render each valid collection
@@ -441,6 +467,32 @@ const AgentFlowNode = ({ data }) => {
const toolName = tool[config.toolProperty]
if (!toolName) return []
// Handle built-in OpenAI tools with icons
if (config.isBuiltInOpenAI) {
const icon = getBuiltInOpenAIToolIcon(toolName)
if (!icon) return []
return [
<Box
key={`tool-${configIndex}-${toolIndex}`}
sx={{
width: 20,
height: 20,
borderRadius: '50%',
backgroundColor: customization.isDarkMode
? darken(data.color, 0.5)
: darken(data.color, 0.2),
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
padding: 0.2
}}
>
{icon}
</Box>
]
}
return [
<Box
key={`tool-${configIndex}-${toolIndex}`}