-
Notifications
You must be signed in to change notification settings - Fork 76
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
[63415] Neural API support for Python SDK #163
[63415] Neural API support for Python SDK #163
Conversation
…eate In preparation for the Neural API. Many Neural objects are objects that extend an existing class (such as `Message`), but unlike `Drafts` the server payload still denotes the `object` key as `message` instead of - say 'signature'
We do this because the Neural API series of endpoints don't support the same operations as the typical Nylas API objects. Thus this allows us to extend the minimum required functionality shared by both the typical Nylas API objects and Neural API objects
This pull request has been linked to Clubhouse Story #63415: Neural API support for Python SDK. |
object_type | ||
and object_type != cls_object_type | ||
and object_type != "account" | ||
and not _is_subclass(cls, object_type) |
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.
Many Neural objects are objects that extend an existing class (such as Message
), but unlike Drafts
the server payload still denotes the object
key as message
instead of - say 'signature'. To prevent this from breaking existing functionality, we check if the class being created is the subclass of the inbound payload's object
value.
return False | ||
|
||
|
||
class RestfulModel(dict): |
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 do this because the Neural API series of endpoints don't support the same operations as the typical Nylas API objects. Thus this allows us to extend the minimum required functionality shared by both the typical Nylas API objects and Neural API objects.
nylas/client/client.py
Outdated
|
||
result = _validate(response).json() | ||
# The Neural API will always return only one item | ||
# but sometimes it returns it in the form of a 'singleton' array |
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.
Is this the restriction of the python SDK? conversation
and signature
can actually return list of objects.
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.
If the endpoints get more than 1 message id, it will return multiple messages
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.
Oops, I did not know that. I thought from the documentation it was always 1:1. I will update the code to reflect this.
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.
@egginsect I have pushed a change to reflect your comments. Does the same apply to OCR? Or does OCR only support one file ID at a time? Thanks!
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.
Yeah it takes only 1 file_id per request
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.
Didn't review for potential bugs, just for the interface, which looks great
New `nylas` v5.0.0 release bringing in the following additions: * Add support for the Nylas Neural API (#163) * Add `metadata` support (#152) * Add new Room Resource fields (#156) * Add `Nylas-API-Version` header support (#157, #151) as well as the following changes: * Transitioned from `app_id` and `app_secret` naming to `client_id` and `client_secret` (#159, #86) * Fix adding a tracking object to an existing `draft` (#153) * Fix issue when converting offset-aware `datetime` objects to `timestamp` (#154, #143) * Fix `limit` value in filter not being used when making `.all()` call (#155) * Fix `from_` field set by attribute on draft ignored (#162, #160) * Remove `bumpversion` from a required dependency to an extra dependency (#158, #144)
Description
This PR brings support for the Nylas Neural API. The Neural API exposes endpoints that perform intelligent analysis on items in your Nylas account. This change will enable users to access the features of the Nylas Neural API and provides some utility functions to help improve the user's workflow.
Usage
To use Sentiment Analysis:
To use Signature Extraction:
and to parse the contact and convert it to the standard Nylas contact object:
To use Clean Conversations:
and to extract images from the result:
To use Optical Character Recognition:
To use Categorizer
License
I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.