-
Notifications
You must be signed in to change notification settings - Fork 623
feat(js/ai): added support for dynamically resolvable resources #3133
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
Conversation
mbleigh
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.
Looking good, few comments and higher-level questions:
- Will resource resolution show up in traces?
- Should we put this in beta or go straight to stable?
- At the moment the action name is the URI but the metadata gets annotated with both the name and the URI - should we either allow an (optional?) name for a resource template or have metadata just be
{resource: {uri: "..."}} - Should we consider the part type being
{resource: {uri: "..."}}instead of{resource: string}? I'm torn, because I like the simplicity a lot but worry if we might add something later...maybe better to keep it simple.
Co-authored-by: Michael Bleigh <bleigh@google.com>
This commit introduces support for both resource templates (using RFC6570) and static URIs in the `defineResource` function. - Added a `template` option to `ResourceOptions` for specifying URI templates. - Updated the resource matching logic to handle both static URIs and templates. - Updated tests to reflect the new functionality. - Added resource metadata to parts.
I'm fine with stable if you're happy with the API.
you're talking about generate message metadata (on the part)? metadata: {
resource: {
name: 'test://resource/{param}',
uri: 'test://resource/value',
},
},
metadata: {
resource: {
name: 'test://resource/{param}',
value: 'test://resource/value',
},
},
yeah... judgement call. It's conceivable that some other options might get added.... |
Co-authored-by: Michael Bleigh <bleigh@google.com>
This commit refactors the resource API to return a content object instead of an array of parts. This change provides a more structured way to return resource content and allows for future expansion of the resource API. The following changes were made: - Updated the `ResourceFn` type to return a `ResourceOutput` object with a `content` property. - Updated the `defineResource` function to return a `ResourceOutput` object. - Updated the `applyResources` function to extract the `content` property from the `ResourceOutput` object. - Updated tests to reflect the new API.
…void circular deps. This commit refactors the `js/ai/src/model.ts` file by: - Moving all type definitions to a new file `js/ai/src/model-types.ts` to improve code organization and readability. - Exporting all types from `js/ai/src/model.ts` to maintain API compatibility. - Updating imports and exports in `js/ai/src/model.ts` to reflect the changes.
…base#3133) Co-authored-by: Michael Bleigh <bleigh@google.com>

Checklist (if applicable):