Skip to content

Commit 1cfaebc

Browse files
committed
Resolve merge conflicts
1 parent d121c18 commit 1cfaebc

File tree

2 files changed

+28
-32
lines changed

2 files changed

+28
-32
lines changed

adalflow/adalflow/components/model_client/openai_client.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,7 @@ def parse_image_generation_response(self, response: List[Image]) -> GeneratorOut
379379
)
380380
except Exception as e:
381381
log.error(f"Error parsing image generation response: {e}")
382-
return GeneratorOutput(
383-
data=None,
384-
error=str(e),
385-
raw_response=str(response)
386-
)
382+
return GeneratorOutput(data=None, error=str(e), raw_response=str(response))
387383

388384
@backoff.on_exception(
389385
backoff.expo,

tutorials/multimodal_client_testing_examples.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,20 @@
1717
from adalflow.core import Generator
1818
from adalflow.components.model_client.openai_client import OpenAIClient
1919
from adalflow.core.types import ModelType
20-
import asyncio
21-
import numpy as np
22-
from dataclasses import dataclass
23-
from typing import List
24-
from numpy.linalg import norm
20+
2521

2622
def test_basic_generation():
2723
"""Test basic text generation"""
2824
client = OpenAIClient() # Default model_type is LLM
2925
gen = Generator(
30-
model_client=client,
31-
model_kwargs={
32-
"model": "gpt-4o-mini",
33-
"max_tokens": 100
34-
}
26+
model_client=client, model_kwargs={"model": "gpt-4o-mini", "max_tokens": 100}
3527
)
36-
28+
3729
print("\n=== Testing Basic Generation ===")
3830
response = gen({"input_str": "Hello, world!"})
3931
print(f"Response: {response}")
4032

33+
4134
def test_invalid_image_url():
4235
"""Test Generator output with invalid image URL"""
4336
client = OpenAIClient() # Default model_type is LLM
@@ -46,14 +39,15 @@ def test_invalid_image_url():
4639
model_kwargs={
4740
"model": "gpt-4o-mini",
4841
"images": "https://invalid.url/nonexistent.jpg",
49-
"max_tokens": 300
50-
}
42+
"max_tokens": 300,
43+
},
5144
)
52-
45+
5346
print("\n=== Testing Invalid Image URL ===")
5447
response = gen({"input_str": "What do you see in this image?"})
5548
print(f"Response with invalid image URL: {response}")
5649

50+
5751
def test_invalid_image_generation():
5852
"""Test DALL-E generation with invalid parameters"""
5953
client = OpenAIClient(model_type=ModelType.IMAGE_GENERATION)
@@ -63,14 +57,15 @@ def test_invalid_image_generation():
6357
"model": "dall-e-3",
6458
"size": "invalid_size", # Invalid size parameter
6559
"quality": "standard",
66-
"n": 1
67-
}
60+
"n": 1,
61+
},
6862
)
69-
63+
7064
print("\n=== Testing Invalid DALL-E Parameters ===")
7165
response = gen({"input_str": "A cat"})
7266
print(f"Response with invalid DALL-E parameters: {response}")
7367

68+
7469
def test_vision_and_generation():
7570
"""Test both vision analysis and image generation"""
7671
# 1. Test Vision Analysis with LLM client
@@ -80,11 +75,13 @@ def test_vision_and_generation():
8075
model_kwargs={
8176
"model": "gpt-4o-mini",
8277
"images": "https://upload.wikimedia.org/wikipedia/en/7/7d/Lenna_%28test_image%29.png",
83-
"max_tokens": 300
84-
}
78+
"max_tokens": 300,
79+
},
80+
)
81+
82+
vision_response = vision_gen(
83+
{"input_str": "What do you see in this image? Be detailed but concise."}
8584
)
86-
87-
vision_response = vision_gen({"input_str": "What do you see in this image? Be detailed but concise."})
8885
print("\n=== Vision Analysis ===")
8986
print(f"Description: {vision_response.raw_response}")
9087

@@ -96,20 +93,23 @@ def test_vision_and_generation():
9693
"model": "dall-e-3",
9794
"size": "1024x1024",
9895
"quality": "standard",
99-
"n": 1
100-
}
96+
"n": 1,
97+
},
10198
)
102-
99+
103100
# For image generation, input_str becomes the prompt
104-
response = dalle_gen({"input_str": "A happy siamese cat playing with a red ball of yarn"})
101+
response = dalle_gen(
102+
{"input_str": "A happy siamese cat playing with a red ball of yarn"}
103+
)
105104
print("\n=== DALL-E Generation ===")
106105
print(f"Generated Image URL: {response.data}")
107106

107+
108108
if __name__ == "__main__":
109109
print("Starting OpenAI Vision and DALL-E test...\n")
110-
110+
111111
# Run all tests - they will show errors if API key is invalid/empty
112112
test_basic_generation()
113113
test_invalid_image_url()
114114
test_invalid_image_generation()
115-
test_vision_and_generation()
115+
test_vision_and_generation()

0 commit comments

Comments
 (0)