fIx: smaller nits
This commit is contained in:
30
frontend/src/hooks/useThinkSections.ts
Normal file
30
frontend/src/hooks/useThinkSections.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Hook for parsing markdown content with think sections.
|
||||
* Extracts <think>...</think> blocks and returns main content and reasoning separately.
|
||||
*/
|
||||
|
||||
import { useMemo } from 'react'
|
||||
import { parseThinkSections } from '@/lib/graph/renderingUtils'
|
||||
|
||||
/**
|
||||
* Parse markdown content and extract think sections.
|
||||
* Returns main content (without think blocks) and reasoning content (from think blocks).
|
||||
*
|
||||
* @param content - The HTML/markdown content to parse
|
||||
* @param outputType - The output type ('image' or 'string')
|
||||
* @returns Object with main and think content
|
||||
*/
|
||||
export function useThinkSections(
|
||||
content: string | null,
|
||||
outputType: 'image' | 'string'
|
||||
): {
|
||||
main: string
|
||||
think: string
|
||||
} {
|
||||
return useMemo(() => {
|
||||
if (!content || outputType === 'image') {
|
||||
return { main: '', think: '' }
|
||||
}
|
||||
return parseThinkSections(content)
|
||||
}, [content, outputType])
|
||||
}
|
||||
Reference in New Issue
Block a user