fix: correct image result format for OpenAI compatibility to fix #632 (#634)

- Change image result type from 'image' to 'image_url' to match OpenAI API expectations
- Wrap image URL in dict structure: {"url": "..."} instead of plain string
- Update SearchResultPostProcessor to handle dict-based image_url during duplicate removal
- Update tests to validate new image format

This fixes the 400 error: Invalid value: 'image'. Supported values are: 'text', 'image_url'...

Co-authored-by: Willem Jiang <143703838+willem-bd@users.noreply.github.com>
This commit is contained in:
Willem Jiang
2025-10-20 23:14:09 +08:00
committed by GitHub
parent 3689bc0e69
commit e2ff765460
3 changed files with 12 additions and 5 deletions

View File

@@ -166,8 +166,8 @@ class TestEnhancedTavilySearchAPIWrapper:
# Test image result
image_result = result[1]
assert image_result["type"] == "image"
assert image_result["image_url"] == "https://example.com/image.jpg"
assert image_result["type"] == "image_url"
assert image_result["image_url"] == {"url": "https://example.com/image.jpg"}
assert image_result["image_description"] == "Test image description"
def test_clean_results_without_raw_content(self, wrapper):