Welcome to Portkey Forum

Updated 3 months ago

Guardrails Implement Error

At a glance

A community member is trying to implement a plugin to integrate with Pangea services, but is encountering an error due to a change in the PluginHandler function. The PluginHandler now requires a 4th parameter called "options", which is breaking the existing plugin implementations. The community member would like to know if they should update all the plugins to include this new parameter or if it can be made optional.

In the comments, another community member suggests that this shouldn't be a blocker for development or testing, as there is no type check happening. However, it turns out there is a type check, and the community member is seeing errors related to the missing "options" parameter.

The community member decides to add the "options" parameter to their implementation, which solves the problem. They also ask if they need to set all the properties of the "options" object, and another community member advises that they can just pass an empty object as long as they are not using any environment variables.

Useful resources
Hi everyone. I'm trying to implement a plugin to integrate with one of out Pangea services (https://pangea.cloud/) and I'm getting and error in all the implemented plugins.
Seems to be that the PluginHandler has changed last month (https://github.com/Portkey-AI/gateway/blob/a66c3a34d57f8724293000a7dc4b4b3399e308ed/plugins/types.ts#L23), it has a 4th parameter called options that it's a required param and it's breaking all the plugins implementations (https://github.com/Portkey-AI/gateway/blob/a66c3a34d57f8724293000a7dc4b4b3399e308ed/plugins/pillar/scanPrompt.ts#L10) . Could someone check it and confirm if that's right or if I had to do something else?
I'd like to know what's the proper plugin interface I should follow
b
A
7 comments
Hey, thanks for trying to implement the plugin and contributing to portkey.

What exactly the error you're facing? PluginHandler is a function type which means a function can read or skip the argument which doesn't seem like an issue to me. Can you share where you're stuck?
Hey, thanks for your help.
I see this error (attached image) in all the plugins tests. That's what I was saying about the 4th parameter breaking old implementation/calls to the plugins.
I would like to know if we should update all the plugins to have this 4th parameter or if this parameter should be optional and that's it
Attachment
image.png
This shouldn't block you with your development or testing because there's no typecheck happening right!?
It seems that there is type check:
Plain Text
plugins % npx jest ./pangea/pangea.test.ts 
 FAIL  pangea/pangea.test.ts
  ● Test suite failed to run

    pangea/pangea.test.ts:20:26 - error TS2554: Expected 4 arguments, but got 3.

    20     const result = await textGuardContentHandler(context, parameters, eventType);
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      types.ts:23:3
        23   options: {
             ~~~~~~~~~~
        24     env: Record<string, any>;
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        25   }
           ~~~
        An argument for 'options' was not provided.
    pangea/pangea.test.ts:34:26 - error TS2554: Expected 4 arguments, but got 3.

    34     const result = await textGuardContentHandler(context, parameters, eventType);
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      types.ts:23:3
        23   options: {
             ~~~~~~~~~~
        24     env: Record<string, any>;
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        25   }
           ~~~
        An argument for 'options' was not provided.
    pangea/pangea.test.ts:51:26 - error TS2554: Expected 4 arguments, but got 3.

    51     const result = await textGuardContentHandler(context, parameters, eventType);
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      types.ts:23:3
        23   options: {
             ~~~~~~~~~~
        24     env: Record<string, any>;
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        25   }
           ~~~
        An argument for 'options' was not provided.

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.164 s, estimated 4 s
Ran all test suites matching /.\/pangea\/pangea.test.ts/i.
Anyway, it's not a big deal, I'll add the options param and problem solved
Also when trying to add and empty object as options it says that it's missing a property. Does it make sense that I have to set all the properties?
Attachment
image.png
You just pass env as empty object. As far as you're not using any environment variables.
Add a reply
Sign up and join the conversation on Discord