Render screenshot in train of thought on openai agent screenshot action

This commit is contained in:
Debanjum
2025-05-04 00:24:25 -06:00
parent 78e052bfcb
commit e71575ad1a
2 changed files with 38 additions and 2 deletions

View File

@@ -352,7 +352,7 @@ export function TrainOfThought(props: TrainOfThoughtProps) {
// Render screenshot image in screenshot action message
let screenshotData = null;
try {
const jsonMatch = message.match(/\{"action": "screenshot".*\}/);
const jsonMatch = message.match(/\{.*("action": "screenshot"|"type": "screenshot").*\}/);
if (jsonMatch) {
screenshotData = JSON.parse(jsonMatch[0]);
const screenshotHtmlString = `<img src="${screenshotData.image}" alt="State of browser" class="max-w-full" />`;