Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
dyastremsky committed Oct 16, 2024
1 parent 9406689 commit 8c0c09b
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,7 @@ def convert(self, generic_dataset: GenericDataset, config: InputsConfig) -> Dict

def _create_payload(self, index: int, row: DataRow, config: InputsConfig) -> Dict[Any, Any]:
model_name = self._select_model_name(config, index)

content: Union[str, List[Dict[Any, Any]]] = ""
if config.output_format == OutputFormat.OPENAI_CHAT_COMPLETIONS:
content = row.texts[0]
elif config.output_format == OutputFormat.OPENAI_VISION or config.output_format == OutputFormat.IMAGE_RETRIEVAL:
content = self._add_multi_modal_content(row)
else:
raise GenAIPerfException(f"Output format {config.output_format} is not supported")
content = self._retrieve_content(row, config)

payload = {
"model": model_name,
Expand All @@ -81,6 +74,15 @@ def _create_payload(self, index: int, row: DataRow, config: InputsConfig) -> Dic
self._add_request_params(payload, config)
return payload

def _retrieve_content(self, row: DataRow, config: InputsConfig) -> Union[str, List[Dict[Any, Any]]]:
content: Union[str, List[Dict[Any, Any]]] = ""
if config.output_format == OutputFormat.OPENAI_CHAT_COMPLETIONS:
content = row.texts[0]
elif config.output_format == OutputFormat.OPENAI_VISION or config.output_format == OutputFormat.IMAGE_RETRIEVAL:
content = self._add_multi_modal_content(row)
else:
raise GenAIPerfException(f"Output format {config.output_format} is not supported")
return content

def _add_multi_modal_content(self, entry: DataRow) -> List[Dict[Any, Any]]:
content = []
Expand Down

0 comments on commit 8c0c09b

Please sign in to comment.