Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions adalflow/adalflow/components/model_client/openai_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def _convert_llm_inputs_to_messages(
def convert_inputs_to_api_kwargs(
self,
input: Optional[Any] = None,
model_kwargs: Dict = {},
model_kwargs: Optional[Dict] = None,
model_type: ModelType = ModelType.UNDEFINED,
) -> Dict:
r"""
Expand All @@ -423,7 +423,7 @@ def convert_inputs_to_api_kwargs(
Dict: API-specific kwargs for the model call
"""

final_model_kwargs = model_kwargs.copy()
final_model_kwargs = model_kwargs.copy() if model_kwargs else {}
if model_type == ModelType.EMBEDDER:
if isinstance(input, str):
input = [input]
Expand Down Expand Up @@ -494,7 +494,11 @@ def parse_image_generation_response(self, response: List[Image]) -> GeneratorOut
),
max_time=5,
)
def call(self, api_kwargs: Dict = {}, model_type: ModelType = ModelType.UNDEFINED):
def call(
self,
api_kwargs: Optional[Dict] = None,
model_type: ModelType = ModelType.UNDEFINED,
):
"""
kwargs is the combined input and model_kwargs. Support streaming call.
For reasoning model, users can add "reasoning" key to the api_kwargs to pass the reasoning config.
Expand All @@ -507,6 +511,7 @@ def call(self, api_kwargs: Dict = {}, model_type: ModelType = ModelType.UNDEFINE
}
}
"""
api_kwargs = api_kwargs or {}
log.info(f"api_kwargs: {api_kwargs}")
self._api_kwargs = api_kwargs
if model_type == ModelType.EMBEDDER:
Expand Down Expand Up @@ -559,12 +564,15 @@ def call(self, api_kwargs: Dict = {}, model_type: ModelType = ModelType.UNDEFINE
max_time=5,
)
async def acall(
self, api_kwargs: Dict = {}, model_type: ModelType = ModelType.UNDEFINED
self,
api_kwargs: Optional[Dict] = None,
model_type: ModelType = ModelType.UNDEFINED,
):
"""
kwargs is the combined input and model_kwargs
"""
# store the api kwargs in the client
api_kwargs = api_kwargs or {}
self._api_kwargs = api_kwargs
if self.async_client is None:
self.async_client = self.init_async_client()
Expand Down
Loading