-
Notifications
You must be signed in to change notification settings - Fork 60
Removing kernal messaging in aqua #1304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…o removing_kernal_messaging_in_aqua
…o removing_kernal_messaging_in_aqua
…/accelerated-data-science into removing_kernal_messaging_in_aqua
1 similar comment
VipulMascarenhas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the PR needs some work, also please add tests to validate the new helper methods added, and the _get_model_deployment_response function to cover:
- chat completions with prompt only
- chat completions with messages
- multimodal with image, with audio
- text completions
- responses
- missing/invalid endpoint_type -> HTTP 400
| if payload.get("stop") == []: | ||
| payload["stop"] = None | ||
|
|
||
| encoded_image = "NA" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the key named NA here? shouldn't we check if "encoded_image" is present in the payload or not?
| {"type": "text", "text": payload["prompt"]}, | ||
| { | ||
| "type": "image_url", | ||
| "image_url": {"url": f"{self.encoded_image}"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks incorrect - self does not have encoded_image attribute
|
|
||
| response = aqua_client.chat.completions.create(**api_kwargs) | ||
|
|
||
| elif self.file_type.startswith("audio"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self does not have file_type attribute, shouldn't this be just file_type?
| {"type": "text", "text": payload["prompt"]}, | ||
| { | ||
| "type": "audio_url", | ||
| "audio_url": {"url": f"{self.encoded_image}"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks incorrect - should encoded_image be passed when file type is audio?
| for chunk in response: | ||
| piece = self._extract_text_from_chunk(chunk) | ||
| if piece: | ||
| print(piece, end="", flush=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this yield instead of printing the chunk?
| yield piece | ||
| except ExtendedRequestError as ex: | ||
| raise HTTPError(400, str(ex)) | ||
| except Exception as ex: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle unknown endpoint type with something like:
else:
raise HTTPError(400, f"Unsupported endpoint_type: {endpoint_type}")
| error_message = ( | ||
| f"Error fetching data from endpoint '{endpoint}' [{error_type}]: {ex}" | ||
| ) | ||
| logger.error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is old code, but has a breaking change. Can we add from ads.aqua import logger import at the top of the file? Else, if this handler is not used at all then we can remove this.
|
|
||
| class AquaDeploymentStreamingInferenceHandler(AquaAPIhandler): | ||
|
|
||
| def _extract_text_from_choice(self, choice): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add docstrings, use type hinting
…o removing_kernal_messaging_in_aqua
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left a few comments. there are a few places where we pop the keys from the payload - mutating the incoming dicts can cause issues while testing or debugging.
can you also add multimodal unit tests once the functionality has been tested?
| and encoded_image != "NA" | ||
| ): | ||
| file_type = payload.pop("file_type") | ||
| if file_type.startswith("image"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can be a bit defensive here - if file_type value is None, it should not fail.
file_type = payload.get("file_type")
if isinstance(file_type, str) and file_type.startswith("image"):
| {"type": "text", "text": payload["prompt"]}, | ||
| { | ||
| "type": "audio_url", | ||
| "audio_url": {"url": f"{encoded_image}"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in case of audio file type, does the content comes from payload["encoded_image"] ? can we use another key for this instead of encoded_image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also it looks like audio is currently not supported by /v1/response api. Instead of adding this code, we can return "unsupported file type" exception.
https://platform.openai.com/docs/guides/audio?example=audio-out#add-audio-to-your-existing-application
| { | ||
| "role": "user", | ||
| "content": [ | ||
| {"type": "text", "text": payload["prompt"]}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here type should be "input_text" and "input_image".
https://platform.openai.com/docs/guides/images-vision#giving-a-model-images-as-input
No description provided.