feat: Refactor workflow result handling in prompts and analysis components
- Introduced a new utility function to streamline the extraction of user-facing content from aggregated workflow results. - Updated backend prompt handling to utilize the new function for improved clarity and maintainability. - Adjusted frontend analysis component to leverage the utility for consistent content display across different workflow result formats. These changes enhance the overall user experience by ensuring more reliable and readable output from workflow executions.
This commit is contained in:
1 parent
300d96a9d8
commit
d803f39de3
3 files changed
+76
-20
No files matched your search
@@ -2,6 +2,7 @@ import React, { useState, useEffect, useMemo } from 'react'
|
||||
import { Brain, Trash2, ChevronDown, ChevronUp } from 'lucide-react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { api } from '../utils/api'
|
||||
import { getWorkflowDisplayContent } from '../utils/workflowDisplay'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import Markdown from '../utils/Markdown'
|
||||
import UsageBadge from '../components/UsageBadge'
|
||||
@@ -400,15 +401,7 @@ export default function Analysis() {
|
||||
content = JSON.stringify(finalOutput, null, 2)
|
||||
}
|
||||
} else if (result.type === 'workflow') {
|
||||
const agg = result.aggregated_result
|
||||
if (agg != null && typeof agg === 'object' && !Array.isArray(agg) && Object.keys(agg).length === 1) {
|
||||
const v = Object.values(agg)[0]
|
||||
content = typeof v === 'string' ? v : JSON.stringify(v, null, 2)
|
||||
} else if (typeof agg === 'string') {
|
||||
content = agg
|
||||
} else {
|
||||
content = JSON.stringify(agg ?? {}, null, 2)
|
||||
}
|
||||
content = getWorkflowDisplayContent(result.aggregated_result)
|
||||
} else {
|
||||
// For base prompts, use output directly
|
||||
content = typeof result.output === 'string' ? result.output : JSON.stringify(result.output, null, 2)
|
||||
|
||||
Reference in new issue
Block a user